Class: MethodSource::Expressions::Expression
- Inherits:
-
Object
- Object
- MethodSource::Expressions::Expression
- Defined in:
- lib/method_source-expressions/expression.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(options) ⇒ Expression
constructor
A new instance of Expression.
- #range ⇒ Object
- #within(other_expression) ⇒ Object
Constructor Details
#initialize(options) ⇒ Expression
Returns a new instance of Expression.
5 6 7 8 9 |
# File 'lib/method_source-expressions/expression.rb', line 5 def initialize() @source = .fetch(:source) @line_number = .fetch(:line_number) @location = .fetch(:location) end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/method_source-expressions/expression.rb', line 3 def location @location end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/method_source-expressions/expression.rb', line 3 def source @source end |
Instance Method Details
#range ⇒ Object
11 12 13 |
# File 'lib/method_source-expressions/expression.rb', line 11 def range is_multi_line? ? multi_line_expression_range : line_number..line_number end |
#within(other_expression) ⇒ Object
15 16 17 18 |
# File 'lib/method_source-expressions/expression.rb', line 15 def within(other_expression) range.all? {|i| other_expression.range.include?(i) } && range != other_expression.range end |