Class: RgGen::VerilogUtility::Identifier
- Inherits:
-
Object
- Object
- RgGen::VerilogUtility::Identifier
show all
- Includes:
- InputBase::RegxpPatterns
- Defined in:
- lib/rggen/core_components/verilog_utility/identifier.rb
Constant Summary
collapse
- TYPE_CONVERSIONS =
[
:to_a, :to_ary, :to_hash, :to_int, :to_io, :to_proc, :to_regexp, :to_str
].freeze
InputBase::RegxpPatterns::BIN_REGEXP, InputBase::RegxpPatterns::DEC_REGEXP, InputBase::RegxpPatterns::HEX_REGEXP, InputBase::RegxpPatterns::OCT_REGEXP, InputBase::RegxpPatterns::UNSIGNED_NUMBER_REGEXP, InputBase::RegxpPatterns::VARIABLE_NAME_REGEXP
Instance Method Summary
collapse
included
Constructor Details
Returns a new instance of Identifier.
6
7
8
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 6
def initialize(name)
@name = name
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 32
def method_missing(name, *args)
return super if args.size > 0
return super if TYPE_CONVERSIONS.include?(name)
return super unless name =~ variable_name
Identifier.new("#{@name}.#{name}")
end
|
Instance Method Details
#[](indexes_or_msb, lsb = indexes_or_msb) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 14
def [](indexes_or_msb, lsb = indexes_or_msb)
if indexes_or_msb.nil?
self
elsif indexes_or_msb.is_a?(Array)
indexes_or_msb.inject(self) do |identifer, index|
identifer[index]
end
elsif indexes_or_msb == lsb
Identifier.new("#{@name}[#{indexes_or_msb}]")
else
Identifier.new("#{@name}[#{indexes_or_msb}:#{lsb}]")
end
end
|
#respond_to_missing?(symbol, include_private) ⇒ Boolean
39
40
41
42
43
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 39
def respond_to_missing?(symbol, include_private)
return super if TYPE_CONVERSIONS.include?(symbol)
return super unless symbol =~ variable_name
true
end
|
#to_s ⇒ Object
10
11
12
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 10
def to_s
@name.to_s
end
|