class Umwelt::Semantic::Base
Attributes
node[R]
Public Class Methods
new(node:)
click to toggle source
# File lib/umwelt/semantic.rb, line 11 def initialize(node:) @node = node end
Public Instance Methods
ancestry_path()
click to toggle source
# File lib/umwelt/semantic.rb, line 19 def ancestry_path ancestry .collect(&:body) .map { |body| underscore(body) } .join '/' end
code()
click to toggle source
# File lib/umwelt/semantic.rb, line 26 def code Unparser.unparse(ast) end
context()
click to toggle source
nil check for case of root node, which has not context
# File lib/umwelt/semantic.rb, line 38 def context node.context&.semantic(:Plain) end
csymbol()
click to toggle source
classified symbol
# File lib/umwelt/semantic.rb, line 43 def csymbol classify(body).to_sym end
label()
click to toggle source
# File lib/umwelt/semantic.rb, line 47 def label self.class.name.split('::').last.to_sym end
path(location: nil)
click to toggle source
default_location defined, for example, in Semantic::Plain::Base
or base file from another semantic
# File lib/umwelt/semantic.rb, line 33 def path(location: nil) Pathname.pwd / (location || default_location) / tail_path end
s(type, *children)
click to toggle source
# File lib/umwelt/semantic.rb, line 15 def s(type, *children) Parser::AST::Node.new(type, children) end
tail_path()
click to toggle source
# File lib/umwelt/semantic.rb, line 51 def tail_path Pathname.new(ancestry_path).sub_ext('.rb') end