Class: Rayo::Models::Renderable

Inherits:
Object
  • Object
show all
Defined in:
lib/rayo/models/renderable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage, file, format, filter) ⇒ Renderable

Returns a new instance of Renderable.



8
9
10
11
12
13
# File 'lib/rayo/models/renderable.rb', line 8

def initialize( storage, file, format, filter )
  @storage = storage
  @file = file
  @format = format
  @filter = filter
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/rayo/models/renderable.rb', line 4

def file
  @file
end

#filterObject (readonly)

Returns the value of attribute filter.



6
7
8
# File 'lib/rayo/models/renderable.rb', line 6

def filter
  @filter
end

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/rayo/models/renderable.rb', line 5

def format
  @format
end

#storageObject (readonly)

Returns the value of attribute storage.



3
4
5
# File 'lib/rayo/models/renderable.rb', line 3

def storage
  @storage
end

Instance Method Details

#render(parser) ⇒ Object



19
20
21
22
23
# File 'lib/rayo/models/renderable.rb', line 19

def render( parser )
  parser.context.with_format @format do
    filter.call( parser.parse( source ) )
  end
end

#sourceObject



15
16
17
# File 'lib/rayo/models/renderable.rb', line 15

def source
  @source ||= @storage.load( file )
end