Class: Yoda::Model::Types::ValueType

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/model/types/value_type.rb

Constant Summary collapse

VALUE_REGEXP =
/\A[0-9a-z]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #map

Constructor Details

#initialize(value) ⇒ ValueType

Returns a new instance of ValueType.

Parameters:

  • value (String)


10
11
12
# File 'lib/yoda/model/types/value_type.rb', line 10

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/yoda/model/types/value_type.rb', line 5

def value
  @value
end

Instance Method Details

#change_root(paths) ⇒ self

Parameters:

  • paths (Array<Path>)

Returns:

  • (self)


26
27
28
# File 'lib/yoda/model/types/value_type.rb', line 26

def change_root(paths)
  self
end

#eql?(another) ⇒ Boolean

Parameters:

  • another (Object)

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/yoda/model/types/value_type.rb', line 15

def eql?(another)
  another.is_a?(ValueType) &&
  value == another.value
end

#hashObject



20
21
22
# File 'lib/yoda/model/types/value_type.rb', line 20

def hash
  [self.class.name, value].hash
end

#resolve(registry) ⇒ Array<YARD::CodeObjects::Base>

Parameters:

  • registry (Registry)

Returns:

  • (Array<YARD::CodeObjects::Base>)


32
33
34
# File 'lib/yoda/model/types/value_type.rb', line 32

def resolve(registry)
  [Store::Query::FindConstant.new(registry).find(value_class)].compact
end

#to_sString

Returns:

  • (String)


52
53
54
# File 'lib/yoda/model/types/value_type.rb', line 52

def to_s
  value
end

#value_classObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/yoda/model/types/value_type.rb', line 36

def value_class
  case value
  when 'true'
    '::TrueClass'
  when 'false'
    '::FalseClass'
  when 'nil'
    '::NilClass'
  when /\A\d+\Z/
    '::Numeric'
  else
    nil
  end
end