OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [lib_inc.rb] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      lib_inc.rb
4
#
5
#  Author:    Christian Hättich
6
#
7
#  Project:   System-On-Chip Maker
8
#
9
#  Target:    Linux / Windows / Mac
10
#
11
#  Language:  ruby
12
#
13
#
14
###############################################################
15
#
16
#
17
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
18
#
19
#   This program is free software: you can redistribute it and/or modify
20
#   it under the terms of the GNU General Public License as published by
21
#   the Free Software Foundation, either version 3 of the License, or
22
#   (at your option) any later version.
23
#
24
#   This program is distributed in the hope that it will be useful,
25
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
26
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
#   GNU General Public License for more details.
28
#
29
#   You should have received a copy of the GNU General Public License
30
#   along with this program.  If not, see .
31
#
32
#
33
###############################################################
34
#
35
#   Description:
36
#
37
#
38
#     A small class, which represents a library-include information.
39
#     The influde directories are stored in @dirs
40
#
41
#
42
###############################################################
43
module SOCMaker
44
class LibInc
45
  include ERR
46
  include YAML_EXT
47
 
48
  attr_accessor :dirs
49
 
50
  def initialize( opts = {} )
51
    init_with( opts )
52
  end
53
 
54
  def encode_with( coder )
55
    %w[ dirs ].
56
      each { |v| coder[ v ] = instance_variable_get "@#{v}" }
57
  end
58
 
59
  def init_with( coder )
60
    serr_if( !( coder.is_a?( Hash         ) ||
61
                coder.is_a?( Psych::Coder ) ),
62
      'coder is not given as Hash neither as Psych::Coder' )
63
    serr_if( coder[ 'dirs' ] == nil,
64
      'no dirs are given' )
65
 
66
    @dirs = coder[ 'dirs' ]
67
 
68
    verr_if( !@dirs.is_a?( Array ),
69
      'dirs must be of type array' )
70
    verr_if( @dirs.size == 0,
71
      'there must be at least one dir-entry')
72
 
73
    @dirs.each do |f|
74
      verr_if( !f.is_a?( String ),
75
        "The dir must be defined as string",
76
        field:    'dirs' )
77
      verr_if( f.size == 0,
78
        "The path string has zero length",
79
        field: 'dirs' )
80
    end
81
  end
82
 
83
 
84
  def ==(o)
85
    o.class == self.class && o.dirs == self.dirs
86
  end
87
 
88
end
89
end
90
 
91
# vim: noai:ts=2:sw=2
92
 
93
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.