Class: Sprockets::SourceLine
- Inherits:
-
Object
- Object
- Sprockets::SourceLine
- Defined in:
- lib/sprockets/source_line.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
Instance Method Summary collapse
- #begins_multiline_comment? ⇒ Boolean
- #begins_pdoc_comment? ⇒ Boolean
- #comment ⇒ Object
- #comment! ⇒ Object
- #comment? ⇒ Boolean
- #ends_multiline_comment? ⇒ Boolean
- #ends_pdoc_comment? ⇒ Boolean
-
#initialize(source_file, line, number) ⇒ SourceLine
constructor
A new instance of SourceLine.
- #inspect ⇒ Object
- #provide ⇒ Object
- #provide? ⇒ Boolean
- #require ⇒ Object
- #require? ⇒ Boolean
- #to_s(constants = source_file.environment.constants) ⇒ Object
Constructor Details
#initialize(source_file, line, number) ⇒ SourceLine
Returns a new instance of SourceLine.
5 6 7 8 9 |
# File 'lib/sprockets/source_line.rb', line 5 def initialize(source_file, line, number) @source_file = source_file @line = line @number = number end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/sprockets/source_line.rb', line 3 def line @line end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/sprockets/source_line.rb', line 3 def number @number end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
3 4 5 |
# File 'lib/sprockets/source_line.rb', line 3 def source_file @source_file end |
Instance Method Details
#begins_multiline_comment? ⇒ Boolean
23 24 25 |
# File 'lib/sprockets/source_line.rb', line 23 def begins_multiline_comment? line =~ /^\s*\/\*(.*)/ end |
#begins_pdoc_comment? ⇒ Boolean
27 28 29 |
# File 'lib/sprockets/source_line.rb', line 27 def begins_pdoc_comment? line =~ /^\s*\/\*\*(.*)/ end |
#comment ⇒ Object
11 12 13 |
# File 'lib/sprockets/source_line.rb', line 11 def comment @comment ||= line[/^\s*\/\/(.*)/, 1] end |
#comment! ⇒ Object
19 20 21 |
# File 'lib/sprockets/source_line.rb', line 19 def comment! @comment = line end |
#comment? ⇒ Boolean
15 16 17 |
# File 'lib/sprockets/source_line.rb', line 15 def comment? !!comment end |
#ends_multiline_comment? ⇒ Boolean
31 32 33 |
# File 'lib/sprockets/source_line.rb', line 31 def ends_multiline_comment? line =~ /^(.*)\*\/\s*/ end |
#ends_pdoc_comment? ⇒ Boolean
35 36 37 |
# File 'lib/sprockets/source_line.rb', line 35 def ends_pdoc_comment? line =~ /^(.*)\*\*\/\s*/ end |
#inspect ⇒ Object
55 56 57 |
# File 'lib/sprockets/source_line.rb', line 55 def inspect "line #@number of #{@source_file.pathname}" end |
#provide ⇒ Object
47 48 49 |
# File 'lib/sprockets/source_line.rb', line 47 def provide @provide ||= (comment || "")[/^=\s+provide\s+\"(.*?)\"\s*$/, 1] end |
#provide? ⇒ Boolean
51 52 53 |
# File 'lib/sprockets/source_line.rb', line 51 def provide? !!provide end |
#require ⇒ Object
39 40 41 |
# File 'lib/sprockets/source_line.rb', line 39 def require @require ||= (comment || "")[/^=\s+require\s+(\"(.*?)\"|<(.*?)>)\s*$/, 1] end |
#require? ⇒ Boolean
43 44 45 |
# File 'lib/sprockets/source_line.rb', line 43 def require? !!require end |
#to_s(constants = source_file.environment.constants) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/sprockets/source_line.rb', line 59 def to_s(constants = source_file.environment.constants) result = line.chomp interpolate_constants!(result, constants) strip_trailing_whitespace!(result) result + $/ end |