Class: Todoist::Command
- Inherits:
-
Object
- Object
- Todoist::Command
- Defined in:
- lib/todoist/command.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#temp_id ⇒ Object
Returns the value of attribute temp_id.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
- #arguments ⇒ Object
-
#initialize(type, object, temp_id = nil, uuid = nil) ⇒ Command
constructor
A new instance of Command.
- #to_hash ⇒ Object
Constructor Details
#initialize(type, object, temp_id = nil, uuid = nil) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 10 |
# File 'lib/todoist/command.rb', line 5 def initialize(type, object, temp_id = nil, uuid = nil) @type = type @object = object @temp_id = object.temp_id @uuid = uuid || SecureRandom.uuid end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/todoist/command.rb', line 3 def object @object end |
#temp_id ⇒ Object
Returns the value of attribute temp_id.
3 4 5 |
# File 'lib/todoist/command.rb', line 3 def temp_id @temp_id end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/todoist/command.rb', line 3 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
3 4 5 |
# File 'lib/todoist/command.rb', line 3 def uuid @uuid end |
Instance Method Details
#arguments ⇒ Object
12 13 14 |
# File 'lib/todoist/command.rb', line 12 def arguments object.to_submittable_hash end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/todoist/command.rb', line 16 def to_hash { type: type, uuid: uuid, args: object.to_submittable_hash }.merge(temp_id ? { temp_id: temp_id} : {}) end |