Class: Ruboty::Variable::Variable
- Inherits:
-
Object
- Object
- Ruboty::Variable::Variable
- Defined in:
- lib/ruboty/variable.rb
Constant Summary collapse
- NAMESPACE =
'variable'
Instance Method Summary collapse
- #array_include?(key, value) ⇒ Boolean
- #array_init(key) ⇒ Object
- #array_push(key, value) ⇒ Object
- #array_remove(key, value) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(message) ⇒ Variable
constructor
A new instance of Variable.
- #set(key, value) ⇒ Object
- #type(key) ⇒ Object
- #values ⇒ Object
Constructor Details
Instance Method Details
#array_include?(key, value) ⇒ Boolean
43 44 45 |
# File 'lib/ruboty/variable.rb', line 43 def array_include?(key, value) values[key][:value].include?(value) if type(key) == 'array' end |
#array_init(key) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ruboty/variable.rb', line 28 def array_init(key) values[key] = { :type => 'array', :value => [] } end |
#array_push(key, value) ⇒ Object
35 36 37 |
# File 'lib/ruboty/variable.rb', line 35 def array_push(key, value) values[key][:value] << value unless array_include?(key, value) end |
#array_remove(key, value) ⇒ Object
39 40 41 |
# File 'lib/ruboty/variable.rb', line 39 def array_remove(key, value) values[key][:value].delete(value) if array_include?(key, value) end |
#get(key) ⇒ Object
20 21 22 |
# File 'lib/ruboty/variable.rb', line 20 def get(key) values[key][:value] if values.has_key?(key) end |
#set(key, value) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/ruboty/variable.rb', line 13 def set(key, value) values[key] = { :type => 'string', :value => value } end |
#type(key) ⇒ Object
24 25 26 |
# File 'lib/ruboty/variable.rb', line 24 def type(key) values[key][:type] if values.has_key?(key) end |
#values ⇒ Object
47 48 49 |
# File 'lib/ruboty/variable.rb', line 47 def values @values end |