Class: Opal::SourceMap
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(fragments, file) ⇒ SourceMap
constructor
A new instance of SourceMap.
- #magic_comment(map_path) ⇒ Object
- #map ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(fragments, file) ⇒ SourceMap
Returns a new instance of SourceMap
9 10 11 12 |
# File 'opal/lib/opal/source_map.rb', line 9 def initialize(fragments, file) @fragments = fragments @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file
7 8 9 |
# File 'opal/lib/opal/source_map.rb', line 7 def file @file end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments
6 7 8 |
# File 'opal/lib/opal/source_map.rb', line 6 def fragments @fragments end |
Instance Method Details
#as_json ⇒ Object
37 38 39 |
# File 'opal/lib/opal/source_map.rb', line 37 def as_json map.as_json end |
#magic_comment(map_path) ⇒ Object
45 46 47 |
# File 'opal/lib/opal/source_map.rb', line 45 def magic_comment map_path "\n//@ sourceMappingURL=file://#{map_path}" end |
#map ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'opal/lib/opal/source_map.rb', line 14 def map @map ||= ::SourceMap.new.tap do |map| line, column = 1, 0 @fragments.each do |fragment| if source_line = fragment.line map.add_mapping( :generated_line => line, :generated_col => column, :source_line => source_line, :source_col => 0, :source => file ) end new_lines = fragment.code.count "\n" line += new_lines column = 0 end end end |
#to_s ⇒ Object
41 42 43 |
# File 'opal/lib/opal/source_map.rb', line 41 def to_s map.to_s end |