Class: Metamorpher::Transformer::Site
- Inherits:
-
Struct
- Object
- Struct
- Metamorpher::Transformer::Site
- Defined in:
- lib/metamorpher/transformer/site.rb
Instance Attribute Summary collapse
-
#original_code ⇒ Object
Returns the value of attribute original_code.
-
#original_position ⇒ Object
Returns the value of attribute original_position.
-
#transformed_code ⇒ Object
Returns the value of attribute transformed_code.
Instance Method Summary collapse
Instance Attribute Details
#original_code ⇒ Object
Returns the value of attribute original_code
5 6 7 |
# File 'lib/metamorpher/transformer/site.rb', line 5 def original_code @original_code end |
#original_position ⇒ Object
Returns the value of attribute original_position
5 6 7 |
# File 'lib/metamorpher/transformer/site.rb', line 5 def original_position @original_position end |
#transformed_code ⇒ Object
Returns the value of attribute transformed_code
5 6 7 |
# File 'lib/metamorpher/transformer/site.rb', line 5 def transformed_code @transformed_code end |
Instance Method Details
#<=>(other) ⇒ Object
24 25 26 |
# File 'lib/metamorpher/transformer/site.rb', line 24 def <=>(other) original_position.begin <=> other.original_position.begin end |
#merge_into(destination) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/metamorpher/transformer/site.rb', line 11 def merge_into(destination) if original_position.begin > destination.size fail ArgumentError, "Position #{original_position} does not exist in: #{destination}" end destination[original_position] = transformed_code destination end |
#offset ⇒ Object
20 21 22 |
# File 'lib/metamorpher/transformer/site.rb', line 20 def offset transformed_code.size - original_code.size end |
#slide(offset) ⇒ Object
6 7 8 9 |
# File 'lib/metamorpher/transformer/site.rb', line 6 def (offset) new_position = (original_position.begin + offset)..(original_position.end + offset) Site.new(new_position, original_code, transformed_code) end |