Class: YmlBuilder::Currencies
- Inherits:
-
Object
- Object
- YmlBuilder::Currencies
- Defined in:
- lib/yml_builder/currencies.rb
Instance Method Summary collapse
-
#initialize ⇒ Currencies
constructor
A new instance of Currencies.
-
#to_yml(ident = 4) ⇒ String
Метод формирует фрагмент YML файла каталога Яндекс.Маркет, содержащий список валют.
Constructor Details
#initialize ⇒ Currencies
Returns a new instance of Currencies.
4 5 6 |
# File 'lib/yml_builder/currencies.rb', line 4 def initialize init_class end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object (private)
66 67 68 69 70 71 72 |
# File 'lib/yml_builder/currencies.rb', line 66 def method_missing(method_sym, *arguments, &block) if @params.include?(method_sym.to_s.gsub(/=$/, '').to_sym) processing_method(method_sym, arguments.first) else super end end |
Instance Method Details
#to_yml(ident = 4) ⇒ String
Метод формирует фрагмент YML файла каталога Яндекс.Маркет, содержащий список валют
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yml_builder/currencies.rb', line 13 def to_yml(ident = 4) out = Array.new out << '<currencies>' @params.each do |key, value| out << " <currency id=#{key.to_s.upcase.inspect} rate=#{value.to_s.upcase.inspect}/>" unless value.nil? end warn "Предупреждение: не указано ни одной валюты в секции 'currencies'" if out.count == 1 out << '</currencies>' out.map! { |line| line = ' '.rjust(ident, ' ') + line } out.join("\n") end |