Class: SmsRu::FreeLimit

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_ru/data.rb

Overview

Result of SmsRu::My#free_limit (free daily messages).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#total_freeInteger (readonly)

Returns the daily allowance of free messages.

Returns:

  • (Integer)

    the daily allowance of free messages



204
205
206
207
208
209
210
211
212
213
# File 'lib/sms_ru/data.rb', line 204

class FreeLimit < Data.define(:total_free, :used_today)
  # @param hash [Hash] the parsed /my/free response
  # @return [SmsRu::FreeLimit]
  def self.build(hash)
    new(total_free: Coerce.integer(hash["total_free"]), used_today: Coerce.integer(hash["used_today"]))
  end

  # @return [Integer] how many free messages remain today
  def available_today = total_free - used_today
end

#used_todayInteger (readonly)

Returns the number used today (0 when the API omits it).

Returns:

  • (Integer)

    the number used today (0 when the API omits it)



204
205
206
207
208
209
210
211
212
213
# File 'lib/sms_ru/data.rb', line 204

class FreeLimit < Data.define(:total_free, :used_today)
  # @param hash [Hash] the parsed /my/free response
  # @return [SmsRu::FreeLimit]
  def self.build(hash)
    new(total_free: Coerce.integer(hash["total_free"]), used_today: Coerce.integer(hash["used_today"]))
  end

  # @return [Integer] how many free messages remain today
  def available_today = total_free - used_today
end

Class Method Details

.build(hash) ⇒ SmsRu::FreeLimit

Parameters:

  • hash (Hash)

    the parsed /my/free response

Returns:



207
208
209
# File 'lib/sms_ru/data.rb', line 207

def self.build(hash)
  new(total_free: Coerce.integer(hash["total_free"]), used_today: Coerce.integer(hash["used_today"]))
end

Instance Method Details

#available_todayInteger

Returns how many free messages remain today.

Returns:

  • (Integer)

    how many free messages remain today



212
# File 'lib/sms_ru/data.rb', line 212

def available_today = total_free - used_today