Class: Opal::EofContent
- Inherits:
-
Object
- Object
- Opal::EofContent
- Defined in:
- opal/lib/opal/eof_content.rb
Constant Summary
- DATA_SEPARATOR =
"__END__\n"
Instance Method Summary collapse
- #eof ⇒ Object
-
#initialize(tokens, source) ⇒ EofContent
constructor
A new instance of EofContent.
Constructor Details
#initialize(tokens, source) ⇒ EofContent
Returns a new instance of EofContent
7 8 9 10 |
# File 'opal/lib/opal/eof_content.rb', line 7 def initialize(tokens, source) @tokens = tokens @source = source end |
Instance Method Details
#eof ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'opal/lib/opal/eof_content.rb', line 12 def eof return nil if @tokens.empty? eof_content = @source[last_token_position..-1] return nil unless eof_content eof_content = eof_content.lines.drop_while { |line| line == "\n" } if eof_content[0] == "__END__\n" eof_content = eof_content[1..-1] || [] eof_content.join elsif eof_content == ['__END__'] '' end end |