Class: Schema2type::SchemaConverter
- Inherits:
-
Object
- Object
- Schema2type::SchemaConverter
- Defined in:
- lib/schema2type/schema_converter.rb
Constant Summary collapse
- TYPE_STRING =
"string"- TYPE_NUMBER =
"number"- TYPE_BOOLEAN =
"string"- TYPE_DATE =
"Date"
Instance Attribute Summary collapse
-
#out_text ⇒ Object
Returns the value of attribute out_text.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #bigint(name, *options) ⇒ Object
- #binary(name, *options) ⇒ Object
- #boolean(name, *options) ⇒ Object
- #date(name, *options) ⇒ Object
- #datetime(name, *options) ⇒ Object
- #decimal(name, *options) ⇒ Object
- #finalize ⇒ Object
- #index(*arg) ⇒ Object
-
#initialize(table_name:) ⇒ SchemaConverter
constructor
A new instance of SchemaConverter.
- #integer(name, *options) ⇒ Object
- #json(name, *options) ⇒ Object
- #string(name, *options) ⇒ Object
- #text(name, *options) ⇒ Object
- #timestamp(name, *options) ⇒ Object
Constructor Details
#initialize(table_name:) ⇒ SchemaConverter
Returns a new instance of SchemaConverter.
13 14 15 16 |
# File 'lib/schema2type/schema_converter.rb', line 13 def initialize(table_name:) @out_text = [] @table_name = table_name end |
Instance Attribute Details
#out_text ⇒ Object
Returns the value of attribute out_text.
5 6 7 |
# File 'lib/schema2type/schema_converter.rb', line 5 def out_text @out_text end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/schema2type/schema_converter.rb', line 6 def table_name @table_name end |
Instance Method Details
#bigint(name, *options) ⇒ Object
35 36 37 |
# File 'lib/schema2type/schema_converter.rb', line 35 def bigint(name, *) push_property_line name: name, type: TYPE_NUMBER, options: end |
#binary(name, *options) ⇒ Object
55 56 57 |
# File 'lib/schema2type/schema_converter.rb', line 55 def binary(name, *) push_property_line name: name, type: TYPE_STRING, options: end |
#boolean(name, *options) ⇒ Object
43 44 45 |
# File 'lib/schema2type/schema_converter.rb', line 43 def boolean(name, *) push_property_line name: name, type: TYPE_BOOLEAN, options: end |
#date(name, *options) ⇒ Object
23 24 25 |
# File 'lib/schema2type/schema_converter.rb', line 23 def date(name, *) push_property_line name: name, type: TYPE_STRING, options: end |
#datetime(name, *options) ⇒ Object
59 60 61 |
# File 'lib/schema2type/schema_converter.rb', line 59 def datetime(name, *) push_property_line name: name, type: TYPE_DATE, options: end |
#decimal(name, *options) ⇒ Object
47 48 49 |
# File 'lib/schema2type/schema_converter.rb', line 47 def decimal(name, *) push_property_line name: name, type: TYPE_NUMBER, options: end |
#finalize ⇒ Object
18 19 20 21 |
# File 'lib/schema2type/schema_converter.rb', line 18 def finalize @out_text.unshift "type #{@table_name.singularize.camelize} = {" @out_text << "}\n" end |
#index(*arg) ⇒ Object
67 68 |
# File 'lib/schema2type/schema_converter.rb', line 67 def index(*arg) end |
#integer(name, *options) ⇒ Object
31 32 33 |
# File 'lib/schema2type/schema_converter.rb', line 31 def integer(name, *) push_property_line name: name, type: TYPE_NUMBER, options: end |
#json(name, *options) ⇒ Object
51 52 53 |
# File 'lib/schema2type/schema_converter.rb', line 51 def json(name, *) push_property_line name: name, type: TYPE_STRING, options: end |
#string(name, *options) ⇒ Object
27 28 29 |
# File 'lib/schema2type/schema_converter.rb', line 27 def string(name, *) push_property_line name: name, type: TYPE_STRING, options: end |
#text(name, *options) ⇒ Object
39 40 41 |
# File 'lib/schema2type/schema_converter.rb', line 39 def text(name, *) push_property_line name: name, type: TYPE_STRING, options: end |
#timestamp(name, *options) ⇒ Object
63 64 65 |
# File 'lib/schema2type/schema_converter.rb', line 63 def (name, *) push_property_line name: name, type: TYPE_DATE, options: end |