Class: EleetScript::ListBase
- Inherits:
-
Object
- Object
- EleetScript::ListBase
- Defined in:
- lib/lang/runtime/base_classes.rb
Instance Attribute Summary collapse
-
#array_value ⇒ Object
Returns the value of attribute array_value.
-
#hash_value ⇒ Object
Returns the value of attribute hash_value.
Instance Method Summary collapse
- #clear ⇒ Object
- #clone ⇒ Object
- #dup ⇒ Object
-
#initialize ⇒ ListBase
constructor
A new instance of ListBase.
- #merge!(o) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ListBase
Returns a new instance of ListBase.
9 10 11 12 |
# File 'lib/lang/runtime/base_classes.rb', line 9 def initialize @array_value = [] @hash_value = {} end |
Instance Attribute Details
#array_value ⇒ Object
Returns the value of attribute array_value.
7 8 9 |
# File 'lib/lang/runtime/base_classes.rb', line 7 def array_value @array_value end |
#hash_value ⇒ Object
Returns the value of attribute hash_value.
7 8 9 |
# File 'lib/lang/runtime/base_classes.rb', line 7 def hash_value @hash_value end |
Instance Method Details
#clear ⇒ Object
41 42 43 44 |
# File 'lib/lang/runtime/base_classes.rb', line 41 def clear array_value.clear hash_value.clear end |
#clone ⇒ Object
19 20 21 |
# File 'lib/lang/runtime/base_classes.rb', line 19 def clone dup end |
#dup ⇒ Object
23 24 25 26 27 28 |
# File 'lib/lang/runtime/base_classes.rb', line 23 def dup ListBase.new.tap do |lst| lst.array_value = array_value.dup lst.hash_value = hash_value.dup end end |
#merge!(o) ⇒ Object
14 15 16 17 |
# File 'lib/lang/runtime/base_classes.rb', line 14 def merge!(o) array_value.concat(o.array_value) hash_value.merge!(o.hash_value) end |
#to_h ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lang/runtime/base_classes.rb', line 30 def to_h {}.tap do |hash| array_value.map.with_index do |value, index| hash[index] = value end hash_value.map do |key, value| hash[key] = value end end end |