Class: Megam::CloudInstruction
- Inherits:
-
Object
- Object
- Megam::CloudInstruction
- Defined in:
- lib/megam/core/cloudinstruction.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action(arg = nil) ⇒ Object
- #cloud_instruction ⇒ Object
- #command(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
-
#initialize ⇒ CloudInstruction
constructor
A new instance of CloudInstruction.
- #name(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ CloudInstruction
Returns a new instance of CloudInstruction.
18 19 20 21 22 |
# File 'lib/megam/core/cloudinstruction.rb', line 18 def initialize @action = nil @command = nil @name = nil end |
Class Method Details
.from_hash(o) ⇒ Object
91 92 93 94 95 |
# File 'lib/megam/core/cloudinstruction.rb', line 91 def self.from_hash(o) cloudinstruction = self.new() cloudinstruction.from_hash(o) cloudinstruction end |
.json_create(o) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/megam/core/cloudinstruction.rb', line 83 def self.json_create(o) cloudinstruction = new cloudinstruction.action(o["action"]) if o.has_key?("action") cloudinstruction.command(o["command"]) if o.has_key?("command") cloudinstruction.name(o["name"]) if o.has_key?("name") cloudinstruction end |
Instance Method Details
#action(arg = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/megam/core/cloudinstruction.rb', line 29 def action(arg=nil) if arg != nil @action = arg else @action end end |
#cloud_instruction ⇒ Object
24 25 26 |
# File 'lib/megam/core/cloudinstruction.rb', line 24 def cloud_instruction self end |
#command(arg = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/megam/core/cloudinstruction.rb', line 37 def command(arg=nil) if arg != nil @command = arg else @command end end |
#error? ⇒ Boolean
53 54 55 |
# File 'lib/megam/core/cloudinstruction.rb', line 53 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/megam/core/cloudinstruction.rb', line 73 def for_json result = { "action" => action, "command" => command, "name" => name } result end |
#from_hash(o) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/megam/core/cloudinstruction.rb', line 97 def from_hash(o) @action = o[:action] if o.has_key?(:action) @command = o[:command] if o.has_key?(:command) @name = o[:name] if o.has_key?(:name) self end |
#name(arg = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/megam/core/cloudinstruction.rb', line 45 def name(arg=nil) if arg != nil @name = arg else @name end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
58 59 60 61 62 63 64 65 |
# File 'lib/megam/core/cloudinstruction.rb', line 58 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["action"] = action index_hash["command"] = command index_hash["name"] = name index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
69 70 71 |
# File 'lib/megam/core/cloudinstruction.rb', line 69 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
105 106 107 |
# File 'lib/megam/core/cloudinstruction.rb', line 105 def to_s Megam::Stuff.styled_hash(to_hash) end |