Class: Shr::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/shr/option.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.indicatorObject

Returns the value of attribute indicator.



6
7
8
# File 'lib/shr/option.rb', line 6

def indicator
  @indicator
end

Class Method Details

.translate(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/shr/option.rb', line 12

def translate(options)
  result = []
  options.each do |opt|
    case opt
    when String then result << opt
    when Symbol then result << translate_from(opt)
    when Fixnum then result << "#{indicator}#{opt}"
    when Hash
      opt.each do |k, v|
        if v.eql?(true)
          result << translate_from(k)
        else
          if k.length > 1
            result << "#{translate_from(k)}=#{v}"
          else
            result << translate_from(k) << v
          end
        end
      end
    end
  end
  result
end