Class: TSJSON::ScalarType
Direct Known Subclasses
AnyType, BooleanType, FloatType, IntType, NullType, StringType
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ ScalarType
constructor
A new instance of ScalarType.
- #to_s ⇒ Object
- #validate(value) ⇒ Object
Methods inherited from Base
#compile, #index, #property, #valid?
Constructor Details
#initialize(name) ⇒ ScalarType
Returns a new instance of ScalarType.
7 8 9 10 |
# File 'lib/types/scalar.rb', line 7 def initialize(name) super() @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/types/scalar.rb', line 5 def name @name end |
Instance Method Details
#to_s ⇒ Object
20 21 22 |
# File 'lib/types/scalar.rb', line 20 def to_s @name end |
#validate(value) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/types/scalar.rb', line 12 def validate(value) raise ScalarValidationError.new( expected_type: @name, received_type: value.class.name, received_value: value ) end |