Class: ERBLint::Utils::BlockMap::ConnectedErbNodes

Inherits:
Object
  • Object
show all
Defined in:
lib/erb_lint/utils/block_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, nodes) ⇒ ConnectedErbNodes

Returns a new instance of ConnectedErbNodes.



49
50
51
52
# File 'lib/erb_lint/utils/block_map.rb', line 49

def initialize(type, nodes)
  @type = type
  @nodes = ordered(nodes)
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



47
48
49
# File 'lib/erb_lint/utils/block_map.rb', line 47

def nodes
  @nodes
end

#typeObject (readonly)

Returns the value of attribute type.



47
48
49
# File 'lib/erb_lint/utils/block_map.rb', line 47

def type
  @type
end

Instance Method Details

#&(other) ⇒ Object



66
67
68
# File 'lib/erb_lint/utils/block_map.rb', line 66

def &(other)
  nodes.select { |node| other.include?(node) }
end

#concat(other) ⇒ Object



54
55
56
# File 'lib/erb_lint/utils/block_map.rb', line 54

def concat(other)
  @nodes = ordered(@nodes.concat(other.nodes))
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/erb_lint/utils/block_map.rb', line 58

def include?(other)
  @nodes.map(&:loc).include?(other.loc)
end

#inspectObject



62
63
64
# File 'lib/erb_lint/utils/block_map.rb', line 62

def inspect
  "\#<#{self.class.name} type=#{type.inspect} nodes=#{nodes.inspect}>"
end