class EnumStateMachine::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/enum_state_machine/yard/handlers/base.rb 8 def extract_node_name(ast) 9 case ast.type 10 when :symbol_literal 11 ast.jump(:ident).source.to_sym 12 when :string_literal 13 ast.jump(:tstring_content).source 14 else 15 nil 16 end 17 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/enum_state_machine/yard/handlers/base.rb 21 def extract_node_names(ast, convert_to_array = true) 22 if [nil, :array].include?(ast.type) 23 ast.children.map {|child| extract_node_name(child)} 24 else 25 node_name = extract_node_name(ast) 26 convert_to_array ? [node_name] : node_name 27 end 28 end