Class: Kumi::Dev::Golden::Representation
- Inherits:
-
Object
- Object
- Kumi::Dev::Golden::Representation
- Defined in:
- lib/kumi/dev/golden/representation.rb
Instance Attribute Summary collapse
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#generator_method ⇒ Object
readonly
Returns the value of attribute generator_method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #filename ⇒ Object
- #generate(schema_path) ⇒ Object
-
#initialize(name, extension:, generator: nil) ⇒ Representation
constructor
A new instance of Representation.
Constructor Details
#initialize(name, extension:, generator: nil) ⇒ Representation
Returns a new instance of Representation.
9 10 11 12 13 |
# File 'lib/kumi/dev/golden/representation.rb', line 9 def initialize(name, extension:, generator: nil) @name = name @extension = extension @generator_method = generator || "generate_#{name}" end |
Instance Attribute Details
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
7 8 9 |
# File 'lib/kumi/dev/golden/representation.rb', line 7 def extension @extension end |
#generator_method ⇒ Object (readonly)
Returns the value of attribute generator_method.
7 8 9 |
# File 'lib/kumi/dev/golden/representation.rb', line 7 def generator_method @generator_method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/kumi/dev/golden/representation.rb', line 7 def name @name end |
Instance Method Details
#filename ⇒ Object
15 16 17 |
# File 'lib/kumi/dev/golden/representation.rb', line 15 def filename "#{name}.#{extension}" end |
#generate(schema_path) ⇒ Object
19 20 21 22 23 |
# File 'lib/kumi/dev/golden/representation.rb', line 19 def generate(schema_path) raise "Unknown generator method: #{generator_method}" unless PrettyPrinter.respond_to?(generator_method) PrettyPrinter.send(generator_method, schema_path) end |