Class: SmsRu::Cost
- Inherits:
-
Object
- Object
- SmsRu::Cost
- Includes:
- MessageCollection
- Defined in:
- lib/sms_ru/data.rb
Overview
Result of SmsRu#cost.
Instance Attribute Summary collapse
-
#messages ⇒ Array<SmsRu::CostItem>
readonly
One entry per recipient.
-
#total_cost ⇒ Float
readonly
The total price across all recipients.
-
#total_sms ⇒ Integer
readonly
The total number of SMS segments.
Class Method Summary collapse
Methods included from MessageCollection
Instance Attribute Details
#messages ⇒ Array<SmsRu::CostItem> (readonly)
Returns one entry per recipient.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/sms_ru/data.rb', line 142 class Cost < Data.define(:total_cost, :total_sms, :messages) include MessageCollection # @param hash [Hash] the parsed /sms/cost response # @return [SmsRu::Cost] def self.build(hash) = Coerce.records(hash["sms"]).map { |phone, cost| CostItem.build(phone, cost) } new( total_cost: Coerce.float(hash["total_cost"]), total_sms: Coerce.integer(hash["total_sms"]), messages: ) end end |
#total_cost ⇒ Float (readonly)
Returns the total price across all recipients.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/sms_ru/data.rb', line 142 class Cost < Data.define(:total_cost, :total_sms, :messages) include MessageCollection # @param hash [Hash] the parsed /sms/cost response # @return [SmsRu::Cost] def self.build(hash) = Coerce.records(hash["sms"]).map { |phone, cost| CostItem.build(phone, cost) } new( total_cost: Coerce.float(hash["total_cost"]), total_sms: Coerce.integer(hash["total_sms"]), messages: ) end end |
#total_sms ⇒ Integer (readonly)
Returns the total number of SMS segments.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/sms_ru/data.rb', line 142 class Cost < Data.define(:total_cost, :total_sms, :messages) include MessageCollection # @param hash [Hash] the parsed /sms/cost response # @return [SmsRu::Cost] def self.build(hash) = Coerce.records(hash["sms"]).map { |phone, cost| CostItem.build(phone, cost) } new( total_cost: Coerce.float(hash["total_cost"]), total_sms: Coerce.integer(hash["total_sms"]), messages: ) end end |
Class Method Details
.build(hash) ⇒ SmsRu::Cost
147 148 149 150 151 152 153 154 |
# File 'lib/sms_ru/data.rb', line 147 def self.build(hash) = Coerce.records(hash["sms"]).map { |phone, cost| CostItem.build(phone, cost) } new( total_cost: Coerce.float(hash["total_cost"]), total_sms: Coerce.integer(hash["total_sms"]), messages: ) end |