Class: ORB::AST::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/ast/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/orb/ast/attribute.rb', line 6

def name
  @name
end

#typeObject (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

#valueObject



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