Class: RBlade::StyleManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rblade/helpers/style_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(styles) ⇒ StyleManager

Returns a new instance of StyleManager.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rblade/helpers/style_manager.rb', line 5

def initialize(styles)
  if styles.is_a? String
    @styles = styles.strip
    unless @styles == "" || @styles.end_with?(";")
      @styles << ";"
    end
  elsif styles.is_a? Array
    @styles = styles.map do |style|
      style = style.strip
      unless style.end_with? ";"
        style << ";"
      end

      style
    end.join
  elsif styles.is_a? Hash
    @styles = +""
    styles.each do |value, predicate|
      if predicate
        value = value.to_s.strip
        unless value.end_with? ";"
          value << ";"
        end

        @styles << value
      end
    end
  end
end

Instance Method Details

#to_sObject



35
36
37
# File 'lib/rblade/helpers/style_manager.rb', line 35

def to_s
  @styles
end

#to_strObject



39
40
41
# File 'lib/rblade/helpers/style_manager.rb', line 39

def to_str
  to_s
end