Class: Parse::Increment

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

Overview

Increment and Decrement


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ Increment

Returns a new instance of Increment.



169
170
171
# File 'lib/parse/datatypes.rb', line 169

def initialize(amount)
  @amount = amount
end

Instance Attribute Details

#amountObject

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



167
168
169
# File 'lib/parse/datatypes.rb', line 167

def amount
  @amount
end

Instance Method Details

#as_json(*a) ⇒ Object



184
185
186
187
188
189
# File 'lib/parse/datatypes.rb', line 184

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

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

Returns:

  • (Boolean)


173
174
175
176
# File 'lib/parse/datatypes.rb', line 173

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

#hashObject



180
181
182
# File 'lib/parse/datatypes.rb', line 180

def hash
  amount.hash
end

#to_json(*a) ⇒ Object



191
192
193
# File 'lib/parse/datatypes.rb', line 191

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