Module: Rucoa::NodeConcerns::Modifier

Included in:
Rucoa::Nodes::IfNode, Rucoa::Nodes::UntilNode, Rucoa::Nodes::WhileNode
Defined in:
lib/rucoa/node_concerns/modifier.rb

Instance Method Summary collapse

Instance Method Details

#modifier?Boolean

Examples:

returns true on modifier if node

node = Rucoa::Source.new(
  content: <<~RUBY,
    1 if true
  RUBY
  uri: 'file:///path/to/example.rb'
).node_at(
  Rucoa::Position.new(
    column: 2,
    line: 1
  )
)
expect(node).to be_modifier

returns false on non-modifier if node

node = Rucoa::Source.new(
  content: <<~RUBY,
    if true
      1
    end
  RUBY
  uri: 'file:///path/to/example.rb'
).root_node
expect(node).not_to be_modifier

Returns:

  • (Boolean)


30
31
32
# File 'lib/rucoa/node_concerns/modifier.rb', line 30

def modifier?
  location.end.nil?
end