class StateMachine::YARD::Handlers::Base

Handles and processes nodes

Private Instance Methods

extract_node_name(ast) click to toggle source

Extracts the value from the node as either a string or symbol

# File lib/state_machine/yard/handlers/base.rb, line 8
def extract_node_name(ast)
  case ast.type
  when :symbol_literal
    ast.jump(:ident).source.to_sym
  when :string_literal
    ast.jump(:tstring_content).source
  else
    nil
  end
end
extract_node_names(ast, convert_to_array = true) click to toggle source

Extracts the values from the node as either strings or symbols. If the node isn't an array, it'll be converted to an array.

# File lib/state_machine/yard/handlers/base.rb, line 21
def extract_node_names(ast, convert_to_array = true)
  if [nil, :array].include?(ast.type)
    ast.children.map {|child| extract_node_name(child)}
  else
    node_name = extract_node_name(ast)
    convert_to_array ? [node_name] : node_name
  end
end