Class: Logue::LocationFormat

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

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD) ⇒ LocationFormat

Returns a new instance of LocationFormat.



18
19
20
21
22
# File 'lib/logue/location_format.rb', line 18

def initialize file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD
  @file   = file
  @line   = line
  @method = method
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



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

def file
  @file
end

#lineObject

Returns the value of attribute line.



15
16
17
# File 'lib/logue/location_format.rb', line 15

def line
  @line
end

#methodObject

Returns the value of attribute method.



16
17
18
# File 'lib/logue/location_format.rb', line 16

def method
  @method
end

Instance Method Details

#format(path, line, cls, methname) ⇒ Object



24
25
26
27
28
29
# File 'lib/logue/location_format.rb', line 24

def format path, line, cls, methname
  name = cls ? cls.to_s + "#" + methname : methname
  path = PathUtil.trim_right path.to_s, @file.abs
  name = PathUtil.trim_left  name,      @method.abs
  sprintf format_string, path, line, name
end

#format_stringObject



31
32
33
# File 'lib/logue/location_format.rb', line 31

def format_string
  "[%#{@file}s:%#{@line}d] {%#{@method}s}"
end