Class: Lumos::Formatters::Base

Inherits:
Object
  • Object
show all
Includes:
BaseChopper, BaseHorizontal
Defined in:
lib/lumos/formatters/base.rb

Direct Known Subclasses

Bottom, Horizontal, Left, Right, Surround, Top, Vertical

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseHorizontal

#horizontal_line, #horizontal_padding, #horizontal_pattern, #horizontal_result

Methods included from BaseChopper

#chopped_message, #chopped_message_length, #chopping_last_line?, #chopping_line, #chopping_padding, #iterate_chopped_lines

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/lumos/formatters/base.rb', line 9

def initialize(options = {})
  @message   = unwrap_message options.fetch(:message)
  @delimiter = options.fetch(:delimiter, "#").to_s
  @padding   = options.fetch(:padding, 1).to_i.abs
  @length    = options.fetch(:length, 70).to_i.abs
end

Instance Attribute Details

#delimiterObject (readonly)

Returns the value of attribute delimiter.



7
8
9
# File 'lib/lumos/formatters/base.rb', line 7

def delimiter
  @delimiter
end

#lengthObject (readonly)

Returns the value of attribute length.



7
8
9
# File 'lib/lumos/formatters/base.rb', line 7

def length
  @length
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/lumos/formatters/base.rb', line 7

def message
  @message
end

#paddingObject (readonly)

Returns the value of attribute padding.



7
8
9
# File 'lib/lumos/formatters/base.rb', line 7

def padding
  @padding
end

Instance Method Details

#message_lengthObject



16
17
18
# File 'lib/lumos/formatters/base.rb', line 16

def message_length
  message.to_s.size
end