Class: SmartTodo::Todo::Compiler
- Inherits:
-
Prism::Compiler
- Object
- Prism::Compiler
- SmartTodo::Todo::Compiler
- Defined in:
- lib/smart_todo/todo.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(metadata) ⇒ Compiler
constructor
A new instance of Compiler.
- #visit_call_node(node) ⇒ Object
- #visit_integer_node(node) ⇒ Object
- #visit_keyword_hash_node(node) ⇒ Object
- #visit_string_node(node) ⇒ Object
Constructor Details
#initialize(metadata) ⇒ Compiler
Returns a new instance of Compiler.
37 38 39 40 |
# File 'lib/smart_todo/todo.rb', line 37 def initialize() super() @metadata = end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
35 36 37 |
# File 'lib/smart_todo/todo.rb', line 35 def @metadata end |
Instance Method Details
#visit_call_node(node) ⇒ Object
42 43 44 |
# File 'lib/smart_todo/todo.rb', line 42 def visit_call_node(node) CallNode.new(node.name, visit_all(node.arguments&.arguments || []), node.location) end |
#visit_integer_node(node) ⇒ Object
46 47 48 |
# File 'lib/smart_todo/todo.rb', line 46 def visit_integer_node(node) node.value end |
#visit_keyword_hash_node(node) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/smart_todo/todo.rb', line 50 def visit_keyword_hash_node(node) node.elements.each do |element| next unless (key = element.key).is_a?(Prism::SymbolNode) case key.unescaped.to_sym when :on value = visit(element.value) if value.is_a?(CallNode) if value.arguments.all? { |arg| arg.is_a?(Integer) || arg.is_a?(String) } .events << value else .errors << "Incorrect `:on` event format: #{value.location.slice}" end else .errors << "Incorrect `:on` event format: #{value.inspect}" end when :to .assignees << visit(element.value) end end end |
#visit_string_node(node) ⇒ Object
73 74 75 |
# File 'lib/smart_todo/todo.rb', line 73 def visit_string_node(node) node.unescaped end |