Class: Bmg::Writer::Text

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Utils

#max

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(text_options = {}, output_preferences = nil)
  @text_options = DEFAULT_OPTIONS.merge(text_options)
  @output_preferences = OutputPreferences.dress(output_preferences)
end

Instance Attribute Details

#output_preferencesObject (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_optionsObject (readonly)

Returns the value of attribute text_options.



169
170
171
# File 'lib/bmg/writer/text.rb', line 169

def text_options
  @text_options
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