Class: ORB::AST::Attribute
- Inherits:
-
Object
- Object
- ORB::AST::Attribute
- Defined in:
- lib/orb/ast/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #bool? ⇒ Boolean
- #directive? ⇒ Boolean
- #dynamic? ⇒ Boolean
- #expression? ⇒ Boolean
-
#initialize(name, type = :str, value = nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #splat? ⇒ Boolean
- #static? ⇒ Boolean
- #string? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(name, type = :str, value = nil) ⇒ Attribute
8 9 10 11 12 |
# File 'lib/orb/ast/attribute.rb', line 8 def initialize(name, type = :str, value = nil) @name = name @type = type @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/orb/ast/attribute.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/orb/ast/attribute.rb', line 6 def type @type end |
Instance Method Details
#bool? ⇒ Boolean
22 23 24 |
# File 'lib/orb/ast/attribute.rb', line 22 def bool? @type == :bool || @type == :boolean end |
#directive? ⇒ Boolean
46 47 48 |
# File 'lib/orb/ast/attribute.rb', line 46 def directive? @name&.start_with?(":") end |
#dynamic? ⇒ Boolean
42 43 44 |
# File 'lib/orb/ast/attribute.rb', line 42 def dynamic? expression? end |
#expression? ⇒ Boolean
26 27 28 |
# File 'lib/orb/ast/attribute.rb', line 26 def expression? @type == :expr || @type == :expression end |
#splat? ⇒ Boolean
34 35 36 |
# File 'lib/orb/ast/attribute.rb', line 34 def splat? @type == :splat end |
#static? ⇒ Boolean
38 39 40 |
# File 'lib/orb/ast/attribute.rb', line 38 def static? string? || bool? end |
#string? ⇒ Boolean
30 31 32 |
# File 'lib/orb/ast/attribute.rb', line 30 def string? @type == :str || @type == :string end |
#value ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/orb/ast/attribute.rb', line 14 def value if @type == :bool || @type == :boolean true else @value end end |