Class: PecCalcClient::Calc
- Inherits:
-
Object
- Object
- PecCalcClient::Calc
- Extended by:
- RequestClass
- Includes:
- RequestObject
- Defined in:
- lib/pec_calc_client/calc.rb
Constant Summary collapse
- URL =
'http://pecom.ru/bitrix/components/pecom/calc/ajax.php'- PARAMS =
%w( plombir strah ashan night pal pallets )
Instance Attribute Summary collapse
-
#delivery ⇒ Object
Returns the value of attribute delivery.
-
#places ⇒ Object
Returns the value of attribute places.
-
#take ⇒ Object
Returns the value of attribute take.
Instance Method Summary collapse
- #calc ⇒ Object
-
#initialize(params) ⇒ Calc
constructor
A new instance of Calc.
- #prepare_params ⇒ Object
Methods included from RequestClass
Methods included from RequestObject
Constructor Details
#initialize(params) ⇒ Calc
Returns a new instance of Calc.
14 15 16 |
# File 'lib/pec_calc_client/calc.rb', line 14 def initialize(params) init_params params end |
Instance Attribute Details
#delivery ⇒ Object
Returns the value of attribute delivery.
12 13 14 |
# File 'lib/pec_calc_client/calc.rb', line 12 def delivery @delivery end |
#places ⇒ Object
Returns the value of attribute places.
12 13 14 |
# File 'lib/pec_calc_client/calc.rb', line 12 def places @places end |
#take ⇒ Object
Returns the value of attribute take.
12 13 14 |
# File 'lib/pec_calc_client/calc.rb', line 12 def take @take end |
Instance Method Details
#calc ⇒ Object
18 19 20 21 |
# File 'lib/pec_calc_client/calc.rb', line 18 def calc result = Connector.new(URL).request(prepare_params) prepare_result result.to_hash end |
#prepare_params ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pec_calc_client/calc.rb', line 23 def prepare_params out = to_h out[:deliver] = @delivery.to_h out[:take] = @take.to_h out[:places] = @places.each_with_index.map { |place, i| [i, place.to_a] }.to_h out end |