Class: Bmg::Writer::Text
- Inherits:
-
Object
- Object
- Bmg::Writer::Text
- Includes:
- Bmg::Writer, Utils
- Defined in:
- lib/bmg/writer/text.rb
Defined Under Namespace
Modules: Utils Classes: Cell, Row, Table
Constant Summary collapse
- TupleLike =
lambda{|t| t.is_a?(Hash) || (defined?(OpenStruct) && t.is_a?(OpenStruct)) }
- RelationLike =
lambda{|r| r.is_a?(Relation) || (r.is_a?(Enumerable) && r.all?{|t| TupleLike === t }) }
- DEFAULT_OPTIONS =
{ }
Instance Attribute Summary collapse
-
#output_preferences ⇒ Object
readonly
Returns the value of attribute output_preferences.
-
#text_options ⇒ Object
readonly
Returns the value of attribute text_options.
Instance Method Summary collapse
- #call(relation, output = "") ⇒ Object (also: #render)
-
#initialize(text_options = {}, output_preferences = nil) ⇒ Text
constructor
A new instance of Text.
Methods included from Utils
Constructor Details
#initialize(text_options = {}, output_preferences = nil) ⇒ Text
Returns a new instance of Text.
165 166 167 168 |
# File 'lib/bmg/writer/text.rb', line 165 def initialize( = {}, output_preferences = nil) = DEFAULT_OPTIONS.merge() @output_preferences = OutputPreferences.dress(output_preferences) end |
Instance Attribute Details
#output_preferences ⇒ Object (readonly)
Returns the value of attribute output_preferences.
169 170 171 |
# File 'lib/bmg/writer/text.rb', line 169 def output_preferences @output_preferences end |
#text_options ⇒ Object (readonly)
Returns the value of attribute text_options.
169 170 171 |
# File 'lib/bmg/writer/text.rb', line 169 def end |
Instance Method Details
#call(relation, output = "") ⇒ Object Also known as: render
171 172 173 174 175 176 |
# File 'lib/bmg/writer/text.rb', line 171 def call(relation, output = "") each_line(relation) do |str| output << str end output end |