Class: GoonModelGen::Source::File
- Inherits:
-
Object
- Object
- GoonModelGen::Source::File
- Includes:
- Contextual
- Defined in:
- lib/goon_model_gen/source/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Attributes included from Contextual
Instance Method Summary collapse
- #basename ⇒ Object
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #new_enum(name, base_type, elements) ⇒ Enum
- #new_named_slice(name, base_type_name) ⇒ Slice
- #new_struct(name) ⇒ Struct
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
17 18 19 20 |
# File 'lib/goon_model_gen/source/file.rb', line 17 def initialize(path) @path = path @types = [] end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/goon_model_gen/source/file.rb', line 13 def path @path end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
14 15 16 |
# File 'lib/goon_model_gen/source/file.rb', line 14 def types @types end |
Instance Method Details
#basename ⇒ Object
22 23 24 |
# File 'lib/goon_model_gen/source/file.rb', line 22 def basename ::File.basename(path, '.*') end |
#new_enum(name, base_type, elements) ⇒ Enum
40 41 42 43 44 45 |
# File 'lib/goon_model_gen/source/file.rb', line 40 def new_enum(name, base_type, elements) Enum.new(name, base_type, elements).tap do |t| t.context = self.context types.push(t) end end |
#new_named_slice(name, base_type_name) ⇒ Slice
50 51 52 53 54 55 |
# File 'lib/goon_model_gen/source/file.rb', line 50 def new_named_slice(name, base_type_name) NamedSlice.new(name, base_type_name).tap do |s| s.context = self.context types.push(s) end end |
#new_struct(name) ⇒ Struct
28 29 30 31 32 33 34 |
# File 'lib/goon_model_gen/source/file.rb', line 28 def new_struct(name) Struct.new(name).tap do |s| s.context = self.context s.file = self types.push(s) end end |