Class: Solargraph::Source::Chain::Literal
- Defined in:
- lib/solargraph/source/chain/literal.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Link
Instance Method Summary collapse
-
#initialize(type, node) ⇒ Literal
constructor
A new instance of Literal.
- #resolve(api_map, name_pin, locals) ⇒ Object
- #word ⇒ Object
Methods inherited from Link
#clone_body, #clone_head, #constant?, #desc, #head?, #inspect, #nullable?, #to_s, #undefined?
Methods included from Logging
Methods included from Equality
Constructor Details
#initialize(type, node) ⇒ Literal
Returns a new instance of Literal.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/solargraph/source/chain/literal.rb', line 17 def initialize type, node if node.is_a?(::Parser::AST::Node) if node.type == :true @value = true elsif node.type == :false @value = false elsif [:int, :sym].include?(node.type) @value = node.children.first end end @type = type @literal_type = ComplexType.try_parse(@value.inspect) @complex_type = ComplexType.try_parse(type) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/solargraph/source/chain/literal.rb', line 13 def value @value end |
Instance Method Details
#resolve(api_map, name_pin, locals) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/solargraph/source/chain/literal.rb', line 37 def resolve api_map, name_pin, locals if api_map.super_and_sub?(@complex_type.name, @literal_type.name) [Pin::ProxyType.anonymous(@literal_type, source: :chain)] else # we don't support this value as a literal type [Pin::ProxyType.anonymous(@complex_type, source: :chain)] end end |
#word ⇒ Object
9 10 11 |
# File 'lib/solargraph/source/chain/literal.rb', line 9 def word @word ||= "<#{@type}>" end |