Class: Typesmith::BaseProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/typesmith/base_property.rb

Direct Known Subclasses

IndexedProperty, NestedProperty, SimpleProperty

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

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/typesmith/base_property.rb', line 8

def name
  @name
end

#optionalObject (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_typescriptObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/typesmith/base_property.rb', line 15

def to_typescript
  raise NotImplementedError, "Subclasses must implement to_typescript"
end