Class: Rhdl::BlockDsl
- Inherits:
-
Object
- Object
- Rhdl::BlockDsl
- Defined in:
- lib/rhdl/block_dsl.rb
Instance Attribute Summary collapse
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Instance Method Summary collapse
- #add_assign_statement(var_name, expr) ⇒ Object
-
#initialize ⇒ BlockDsl
constructor
A new instance of BlockDsl.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize ⇒ BlockDsl
Returns a new instance of BlockDsl.
40 41 42 43 44 |
# File 'lib/rhdl/block_dsl.rb', line 40 def initialize @variables = {} @statements = [] @trap = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rhdl/block_dsl.rb', line 46 def method_missing(name, *args) super if args.length != 0 super if @trap @trap = true v = @variables[name] if v.nil? v = Variable.new(name, self) @variables[name] = v end @trap = false v end |
Instance Attribute Details
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
39 40 41 |
# File 'lib/rhdl/block_dsl.rb', line 39 def statements @statements end |
Instance Method Details
#add_assign_statement(var_name, expr) ⇒ Object
60 61 62 |
# File 'lib/rhdl/block_dsl.rb', line 60 def add_assign_statement(var_name, expr) @statements << AssignStatement.new(var_name, expr) end |