Class: Odin::Types::OdinVerbExpression

Inherits:
OdinValue
  • Object
show all
Defined in:
lib/odin/types/values.rb

Instance Attribute Summary collapse

Attributes inherited from OdinValue

#directives, #modifiers

Instance Method Summary collapse

Methods inherited from OdinValue

#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?

Constructor Details

#initialize(verb, is_custom: false, args: [], **kwargs) ⇒ OdinVerbExpression

Returns a new instance of OdinVerbExpression.



497
498
499
500
501
502
503
# File 'lib/odin/types/values.rb', line 497

def initialize(verb, is_custom: false, args: [], **kwargs)
  super(**kwargs)
  @verb = -verb.to_s
  @is_custom = is_custom
  @args = args.freeze
  freeze
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



495
496
497
# File 'lib/odin/types/values.rb', line 495

def args
  @args
end

#is_customObject (readonly)

Returns the value of attribute is_custom.



495
496
497
# File 'lib/odin/types/values.rb', line 495

def is_custom
  @is_custom
end

#verbObject (readonly)

Returns the value of attribute verb.



495
496
497
# File 'lib/odin/types/values.rb', line 495

def verb
  @verb
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



511
512
513
514
# File 'lib/odin/types/values.rb', line 511

def ==(other)
  other.is_a?(OdinVerbExpression) && verb == other.verb &&
    is_custom == other.is_custom && args == other.args
end

#custom?Boolean

Returns:

  • (Boolean)


507
508
509
# File 'lib/odin/types/values.rb', line 507

def custom?
  @is_custom
end

#hashObject



517
518
519
# File 'lib/odin/types/values.rb', line 517

def hash
  [ValueType::VERB, verb, is_custom, args].hash
end

#to_sObject



521
522
523
# File 'lib/odin/types/values.rb', line 521

def to_s
  "%#{verb}(#{args.join(', ')})"
end

#typeObject



505
# File 'lib/odin/types/values.rb', line 505

def type; ValueType::VERB; end

#with_directives(dirs) ⇒ Object



530
531
532
533
# File 'lib/odin/types/values.rb', line 530

def with_directives(dirs)
  OdinVerbExpression.new(verb, is_custom: is_custom, args: args,
                               modifiers: modifiers, directives: dirs)
end

#with_modifiers(mods) ⇒ Object



525
526
527
528
# File 'lib/odin/types/values.rb', line 525

def with_modifiers(mods)
  OdinVerbExpression.new(verb, is_custom: is_custom, args: args,
                               modifiers: mods, directives: directives)
end