Class: Rhdl::DataType

Inherits:
Object
  • Object
show all
Defined in:
lib/rhdl/data_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, bits, parent) ⇒ DataType

Returns a new instance of DataType.



5
6
7
8
9
# File 'lib/rhdl/data_type.rb', line 5

def initialize(name, bits, parent)
  @name = name
  @bits = bits
  @parent = parent
end

Instance Attribute Details

#bitsObject (readonly)

Returns the value of attribute bits.



3
4
5
# File 'lib/rhdl/data_type.rb', line 3

def bits
  @bits
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rhdl/data_type.rb', line 3

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/rhdl/data_type.rb', line 3

def parent
  @parent
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/rhdl/data_type.rb', line 15

def ==(other)
  name == other.name && bits == other.bits
end

#is_equal_or_child_of(other) ⇒ Object



19
20
21
22
23
24
# File 'lib/rhdl/data_type.rb', line 19

def is_equal_or_child_of(other)
  return false if parent.nil?
  return true if other == self
  
  parent.is_equal_or_child_of(other)
end

#to_sObject



26
27
28
# File 'lib/rhdl/data_type.rb', line 26

def to_s
  "#{@name}_#{@bits}"
end

#with_bits(bits) ⇒ Object



11
12
13
# File 'lib/rhdl/data_type.rb', line 11

def with_bits(bits)
  DataType.new(@name, bits, parent)
end