Class: Logue::LocationFormat
- Inherits:
-
Object
- Object
- Logue::LocationFormat
- Defined in:
- lib/logue/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_string ⇒ Object
-
#initialize(file: Defaults::FILENAME, line: Defaults::LINE, method: Defaults::METHOD) ⇒ LocationFormat
constructor
A new instance of LocationFormat.
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
#file ⇒ Object
Returns the value of attribute file.
14 15 16 |
# File 'lib/logue/location_format.rb', line 14 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
15 16 17 |
# File 'lib/logue/location_format.rb', line 15 def line @line end |
#method ⇒ Object
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_string ⇒ Object
31 32 33 |
# File 'lib/logue/location_format.rb', line 31 def format_string "[%#{@file}s:%#{@line}d] {%#{@method}s}" end |