Module: Inkjet::Styles::Formatters

Included in:
Inkjet
Defined in:
lib/inkjet/styles.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/inkjet/styles.rb', line 28

def method_missing(meth, *args)
  if meth.match(/\A(#{Inkjet::Styles::Styles.join("|")})(!?)\Z/)
    stylize($1, *args)
  else
    super(meth, *args)
  end
end

Class Method Details

.included(base) ⇒ Object



16
17
18
# File 'lib/inkjet/styles.rb', line 16

def self.included(base)
  base.send :extend, self
end

Instance Method Details

#stylize(style, str, wrap = false) ⇒ Object



20
21
22
# File 'lib/inkjet/styles.rb', line 20

def stylize(style, str, wrap=false)
  stylize!(style, str.clone, wrap)
end

#stylize!(style, str, wrap = false) ⇒ Object



24
25
26
# File 'lib/inkjet/styles.rb', line 24

def stylize!(style, str, wrap=false)
  str.apply_inkjet_code!(Inkjet::Styles.style(style), wrap)
end