Class: Logue::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/logue/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, msg, obj = nil, &blk) ⇒ Line

Returns a new instance of Line.



15
16
17
18
19
20
# File 'lib/logue/line.rb', line 15

def initialize location, msg, obj = nil, &blk
  @location = location
  @msg = msg
  @obj = obj
  @block = blk
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



13
14
15
# File 'lib/logue/line.rb', line 13

def block
  @block
end

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/logue/line.rb', line 10

def location
  @location
end

#msgObject (readonly)

Returns the value of attribute msg.



11
12
13
# File 'lib/logue/line.rb', line 11

def msg
  @msg
end

#objObject (readonly)

Returns the value of attribute obj.



12
13
14
# File 'lib/logue/line.rb', line 12

def obj
  @obj
end

Instance Method Details

#format(locformat) ⇒ Object



40
41
42
# File 'lib/logue/line.rb', line 40

def format locformat
  location_string(locformat) + " " + message_string
end

#location_string(locformat) ⇒ Object



22
23
24
# File 'lib/logue/line.rb', line 22

def location_string locformat
  @location.format locformat
end

#message_stringObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/logue/line.rb', line 26

def message_string
  if @block
    @block.call.to_s
  elsif @obj
    elmt = Element.new @obj
    io = StringIO.new
    elmt.write io
    io.close
    @msg.to_s + ": " + io.string
  else
    @msg.to_s
  end
end