Class: Rayo::Config::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/rayo/config/format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Format

Returns a new instance of Format.



6
7
8
9
10
# File 'lib/rayo/config/format.rb', line 6

def initialize( name )
  @name = name.to_s
  @filters = { @name => lambda{|source| source} }
  @renderable_exts = [ ".#{name}" ]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rayo/config/format.rb', line 3

def name
  @name
end

#renderable_extsObject (readonly)

Returns the value of attribute renderable_exts.



4
5
6
# File 'lib/rayo/config/format.rb', line 4

def renderable_exts
  @renderable_exts
end

Instance Method Details

#add_filter(from, &filter) ⇒ Object

Add filter

Parameters:

  • renderable (String, Symbol)

    file extension

  • filter (Proc)

    proc which accepts source and return it in processed form



16
17
18
19
# File 'lib/rayo/config/format.rb', line 16

def add_filter( from, &filter )
  @filters[from.to_s] = filter
  @renderable_exts << ".#{from}" unless @renderable_exts.include? ".#{from}"
end

#filter(from) ⇒ Object



21
22
23
# File 'lib/rayo/config/format.rb', line 21

def filter( from )
  @filters[from.to_s]
end