Class: LC::Increment
- Inherits:
-
Object
- Object
- LC::Increment
- Defined in:
- lib/leancloud/datatypes.rb
Overview
Increment and Decrement
Instance Attribute Summary collapse
-
#amount ⇒ Object
‘{“score”: {“__op”: “Increment”, “amount”: 1 } }’.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(amount) ⇒ Increment
constructor
A new instance of Increment.
- #to_h(*a) ⇒ Object (also: #as_json)
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(amount) ⇒ Increment
Returns a new instance of Increment.
186 187 188 |
# File 'lib/leancloud/datatypes.rb', line 186 def initialize(amount) @amount = amount end |
Instance Attribute Details
#amount ⇒ Object
‘{“score”: {“__op”: “Increment”, “amount”: 1 } }’
184 185 186 |
# File 'lib/leancloud/datatypes.rb', line 184 def amount @amount end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
190 191 192 193 |
# File 'lib/leancloud/datatypes.rb', line 190 def eql?(other) self.class.equal?(other.class) && amount == other.amount end |
#hash ⇒ Object
197 198 199 |
# File 'lib/leancloud/datatypes.rb', line 197 def hash amount.hash end |
#to_h(*a) ⇒ Object Also known as: as_json
201 202 203 204 205 206 |
# File 'lib/leancloud/datatypes.rb', line 201 def to_h(*a) { Protocol::KEY_OP => Protocol::KEY_INCREMENT, Protocol::KEY_AMOUNT => @amount } end |
#to_json(*a) ⇒ Object
209 210 211 |
# File 'lib/leancloud/datatypes.rb', line 209 def to_json(*a) to_h.to_json(*a) end |