Class: CreateLookup
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Base
Instance Method Summary collapse
- #arduino_code ⇒ Object
-
#initialize(params) ⇒ CreateLookup
constructor
A new instance of CreateLookup.
- #param_keys ⇒ Object
- #table_to_cplusplus_array(t) ⇒ Object
- #top_level_scope_code ⇒ Object
Methods inherited from Base
#add_arduino_code, #add_cycle_level_scope, #add_top_level_scope, #append_tsortable, #buildit, #cycle_level_arduino_code, #depends_on, #resolve_frame_optimized, #top_level_scope_arduino_code
Constructor Details
#initialize(params) ⇒ CreateLookup
Returns a new instance of CreateLookup.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/functions/create_lookup.rb', line 13 def initialize(params) super(params) @identifier = params[:identifier] unless $tables.has_key?(@identifier) $tables[@identifier] = params[:value] @value = params[:value] else raise "duplicate table definition #{params[:name]}" end end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
10 11 12 |
# File 'lib/functions/create_lookup.rb', line 10 def identifier @identifier end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/functions/create_lookup.rb', line 11 def value @value end |
Instance Method Details
#arduino_code ⇒ Object
28 29 30 |
# File 'lib/functions/create_lookup.rb', line 28 def arduino_code [] end |
#param_keys ⇒ Object
24 25 26 |
# File 'lib/functions/create_lookup.rb', line 24 def param_keys [] end |
#table_to_cplusplus_array(t) ⇒ Object
38 39 40 |
# File 'lib/functions/create_lookup.rb', line 38 def table_to_cplusplus_array(t) "{#{t.map {|f| f.to_s.gsub(/\[/, '{').gsub(/\]/, '}') }.join(',')}}" end |
#top_level_scope_code ⇒ Object
32 33 34 35 36 |
# File 'lib/functions/create_lookup.rb', line 32 def top_level_scope_code [ "long #{@identifier}[#{@value.length}][3] = #{table_to_cplusplus_array(@value)};" ] end |