Class: WriteDown::Model::Container
- Inherits:
-
Object
- Object
- WriteDown::Model::Container
- Defined in:
- lib/write_down/model/container.rb
Overview
基类, 定义了一些接口
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #append(item) ⇒ Object
- #build ⇒ Object
-
#initialize(target_file, options = {}) ⇒ Container
constructor
A new instance of Container.
- #render ⇒ Object
Constructor Details
#initialize(target_file, options = {}) ⇒ Container
12 13 14 15 16 |
# File 'lib/write_down/model/container.rb', line 12 def initialize(target_file, = {}) @target_file = target_file @items = [] @options = end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
10 11 12 |
# File 'lib/write_down/model/container.rb', line 10 def items @items end |
Instance Method Details
#append(item) ⇒ Object
29 30 31 32 |
# File 'lib/write_down/model/container.rb', line 29 def append(item) @items << item self end |
#build ⇒ Object
24 25 26 27 |
# File 'lib/write_down/model/container.rb', line 24 def build Layout.new(self, @target_file, @options).render self end |
#render ⇒ Object
18 19 20 21 22 |
# File 'lib/write_down/model/container.rb', line 18 def render template_file = File.('../../erb/container.erb', __FILE__) template = File.read(template_file) html_string = ERB.new(template).result(binding) end |