class Estreet::Node

Attributes

source_location[R]

Public Class Methods

new(loc=nil) click to toggle source
# File lib/estreet/node.rb, line 6
def initialize(loc=nil)
  @source_location = loc
end

Public Instance Methods

as_json() click to toggle source
# File lib/estreet/node.rb, line 19
def as_json
  attributes.map {|k,v|
    case v
    when Estreet::Node
      [k, v.as_json]
    when Array
      [k, v.map(&:as_json)]
    else
      [k, v]
    end
  }.to_h
  # raise NotImplementedError
end
loc(source_location) click to toggle source
# File lib/estreet/node.rb, line 10
def loc(source_location)
  @source_location = loc # TODO: construct the thing
  self # suitable for chaining
end
type() click to toggle source
# File lib/estreet/node.rb, line 15
def type
  self.class.name.gsub(/\AEstreet::/, '')
end

Private Instance Methods

attributes() click to toggle source
# File lib/estreet/node.rb, line 35
def attributes
  { type: type }.tap do |h|
    h[:loc] = @source_location if @source_location
  end
end