Class: Lumb::Structure
- Inherits:
-
Object
- Object
- Lumb::Structure
- Defined in:
- lib/lumb/structure.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#ws ⇒ Object
readonly
Returns the value of attribute ws.
Instance Method Summary collapse
-
#initialize(items, ws) ⇒ Structure
constructor
A new instance of Structure.
- #slot_index(name) ⇒ Object
- #slot_type(name_or_index) ⇒ Object
Constructor Details
#initialize(items, ws) ⇒ Structure
Returns a new instance of Structure.
5 6 7 8 9 10 11 12 |
# File 'lib/lumb/structure.rb', line 5 def initialize(items, ws) @items, @ws = items, ws @slots = {} @items.map.with_index do |item, idx| @slots[item.slot] = idx end end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
3 4 5 |
# File 'lib/lumb/structure.rb', line 3 def items @items end |
#ws ⇒ Object (readonly)
Returns the value of attribute ws.
3 4 5 |
# File 'lib/lumb/structure.rb', line 3 def ws @ws end |
Instance Method Details
#slot_index(name) ⇒ Object
14 15 16 |
# File 'lib/lumb/structure.rb', line 14 def slot_index(name) @slots[name.to_sym] end |
#slot_type(name_or_index) ⇒ Object
18 19 20 21 |
# File 'lib/lumb/structure.rb', line 18 def slot_type(name_or_index) name_or_index = slot_index(name_or_index) unless name_or_index.is_a? Fixnum @items[name_or_index].type end |