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.



178
179
180
# File 'lib/parse/datatypes.rb', line 178

def initialize(amount)
  @amount = amount
end

Instance Attribute Details

#amountObject

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



176
177
178
# File 'lib/parse/datatypes.rb', line 176

def amount
  @amount
end

Instance Method Details

#as_json(*a) ⇒ Object



193
194
195
196
197
198
# File 'lib/parse/datatypes.rb', line 193

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

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

Returns:

  • (Boolean)


182
183
184
185
# File 'lib/parse/datatypes.rb', line 182

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

#hashObject



189
190
191
# File 'lib/parse/datatypes.rb', line 189

def hash
  amount.hash
end

#to_json(*a) ⇒ Object



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

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