Class: Logue::LocationFormat
- Inherits:
-
Object
- Object
- Logue::LocationFormat
- Defined in:
- lib/logue/format/location_format.rb
Defined Under Namespace
Modules: Defaults
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
- #format(path, line, cls, methname) ⇒ Object
- #format_location(location) ⇒ Object
- #format_string ⇒ Object
-
#initialize(file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD) ⇒ LocationFormat
constructor
A new instance of LocationFormat.
- #to_s ⇒ Object
Constructor Details
#initialize(file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD) ⇒ LocationFormat
Returns a new instance of LocationFormat.
15 16 17 18 19 |
# File 'lib/logue/format/location_format.rb', line 15 def initialize file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD @file = file @line = line @method = method end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
11 12 13 |
# File 'lib/logue/format/location_format.rb', line 11 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
12 13 14 |
# File 'lib/logue/format/location_format.rb', line 12 def line @line end |
#method ⇒ Object
Returns the value of attribute method.
13 14 15 |
# File 'lib/logue/format/location_format.rb', line 13 def method @method end |
Instance Method Details
#format(path, line, cls, methname) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/logue/format/location_format.rb', line 21 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_location(location) ⇒ Object
28 29 30 |
# File 'lib/logue/format/location_format.rb', line 28 def format_location location format location.path, location.line, location.cls, location.method end |
#format_string ⇒ Object
32 33 34 |
# File 'lib/logue/format/location_format.rb', line 32 def format_string "[%#{@file}s:%#{@line}d] {%#{@method}s}" end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/logue/format/location_format.rb', line 36 def to_s inspect end |