Class: Parse::Decrement

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/datatypes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ Decrement

Returns a new instance of Decrement.



200
201
202
# File 'lib/parse/datatypes.rb', line 200

def initialize(amount)
  @amount = amount
end

Instance Attribute Details

#amountObject

‘{“score”: {“__op”: “Decrement”, “amount”: 1 } }’



198
199
200
# File 'lib/parse/datatypes.rb', line 198

def amount
  @amount
end

Instance Method Details

#as_json(*a) ⇒ Object



215
216
217
218
219
220
# File 'lib/parse/datatypes.rb', line 215

def as_json(*a)
  {
      Protocol::KEY_OP => Protocol::KEY_DECREMENT,
      Protocol::KEY_AMOUNT => @amount
  }
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


204
205
206
207
# File 'lib/parse/datatypes.rb', line 204

def eql?(other)
  self.class.equal?(other.class) &&
    amount == other.amount
end

#hashObject



211
212
213
# File 'lib/parse/datatypes.rb', line 211

def hash
  amount.hash
end

#to_json(*a) ⇒ Object



222
223
224
# File 'lib/parse/datatypes.rb', line 222

def to_json(*a)
    as_json.to_json(*a)
end