Class: StringT

Inherits:
Any show all
Defined in:
lib/types/string_t.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Any

#t, #t=, #to_s

Constructor Details

#initialize(value) ⇒ StringT

Returns a new instance of StringT.



46
# File 'lib/types/string_t.rb', line 46

def initialize(value) = super(setup_value(value))

Class Method Details

.t(*values) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/types/string_t.rb', line 9

def t(*values)
  validated_values = ArrayT.new(
    values.map do |value|
      raise RubytTypeError.new(StringT, value.class) unless value.is_a? StringT

      value
    end
  )

  return validated_values.t.first if validated_values.t.length == 1

  validated_values
end

Instance Method Details

#!=(other) ⇒ Object



52
53
54
# File 'lib/types/string_t.rb', line 52

def !=(other)
  !(other.is_a?(StringT) && other.t == @value)
end

#==(other) ⇒ Object



48
49
50
# File 'lib/types/string_t.rb', line 48

def ==(other)
  other.is_a?(StringT) && other.t == @value
end