Class: Mist::CodeExampleParser::Example
- Inherits:
-
String
- Object
- String
- Mist::CodeExampleParser::Example
- Defined in:
- lib/mist/code_example_parser.rb
Constant Summary collapse
- FILENAME_REGEXP =
/\A[\s\t\n]*file: (.*?)[\n\r]+/
Instance Attribute Summary collapse
- #filename ⇒ Object
-
#start_offset ⇒ Object
Returns the value of attribute start_offset.
-
#whitespace_skipped ⇒ Object
Returns the value of attribute whitespace_skipped.
Instance Method Summary collapse
- #explicit_filename ⇒ Object
-
#initialize(start_offset) ⇒ Example
constructor
A new instance of Example.
- #offset ⇒ Object
Constructor Details
#initialize(start_offset) ⇒ Example
Returns a new instance of Example.
10 11 12 13 14 |
# File 'lib/mist/code_example_parser.rb', line 10 def initialize(start_offset) @whitespace_skipped = 0 @start_offset = start_offset super() end |
Instance Attribute Details
#filename ⇒ Object
28 29 30 |
# File 'lib/mist/code_example_parser.rb', line 28 def filename @filename || explicit_filename end |
#start_offset ⇒ Object
Returns the value of attribute start_offset.
5 6 7 |
# File 'lib/mist/code_example_parser.rb', line 5 def start_offset @start_offset end |
#whitespace_skipped ⇒ Object
Returns the value of attribute whitespace_skipped.
6 7 8 |
# File 'lib/mist/code_example_parser.rb', line 6 def whitespace_skipped @whitespace_skipped end |
Instance Method Details
#explicit_filename ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mist/code_example_parser.rb', line 16 def explicit_filename @explicit_filename ||= if self =~ FILENAME_REGEXP # omit filename from self match = $~ @whitespace_skipped += match.offset(0)[1] - match.offset(0)[0] sub! match[0], '' match[1] else nil end end |
#offset ⇒ Object
32 33 34 |
# File 'lib/mist/code_example_parser.rb', line 32 def offset start_offset...(start_offset+length+whitespace_skipped) end |