Class: Typesmith::BaseProperty
- Inherits:
-
Object
- Object
- Typesmith::BaseProperty
- Defined in:
- lib/typesmith/base_property.rb
Direct Known Subclasses
Defined Under Namespace
Classes: InvalidTypeError
Constant Summary collapse
- PRIMITIVE_TYPES =
%i[string number boolean any null undefined void never unknown object Date].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
Instance Method Summary collapse
-
#initialize(name, optional: false) ⇒ BaseProperty
constructor
A new instance of BaseProperty.
- #process_value(value) ⇒ Object
- #to_typescript ⇒ Object
Constructor Details
#initialize(name, optional: false) ⇒ BaseProperty
Returns a new instance of BaseProperty.
10 11 12 13 |
# File 'lib/typesmith/base_property.rb', line 10 def initialize(name, optional: false) @name = name @optional = optional end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/typesmith/base_property.rb', line 8 def name @name end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
8 9 10 |
# File 'lib/typesmith/base_property.rb', line 8 def optional @optional end |
Instance Method Details
#process_value(value) ⇒ Object
19 20 21 |
# File 'lib/typesmith/base_property.rb', line 19 def process_value(value) value end |
#to_typescript ⇒ Object
15 16 17 |
# File 'lib/typesmith/base_property.rb', line 15 def to_typescript raise NotImplementedError, "Subclasses must implement to_typescript" end |