Class: DSLCompose::ReaderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl_compose/reader_base.rb

Overview

This class provides a skeleton for creating your own DSL readers.

All classes which extend from this base class must follow a strict naming convention. The class name must be the camelcased form of the DSL name, followed by the string “DSLReader”. For example, a reader for a DLS named ‘:foo_bar` must have the class name `FooBarDSLReader`, as seen below

class FooBarDSLReader < DSLCompose::ReaderBase

# ...

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_class) ⇒ ReaderBase

Returns a new instance of ReaderBase.



16
17
18
19
20
21
22
# File 'lib/dsl_compose/reader_base.rb', line 16

def initialize base_class
  @base_class = base_class
  # get the DSL name from the class name
  @dsl_name = dsl_name_from_class_name self.class
  # create the reader
  @reader = DSLCompose::Reader.new(base_class, @dsl_name)
end

Instance Attribute Details

#base_classObject (readonly)

Returns the value of attribute base_class.



12
13
14
# File 'lib/dsl_compose/reader_base.rb', line 12

def base_class
  @base_class
end

#dsl_nameObject (readonly)

Returns the value of attribute dsl_name.



13
14
15
# File 'lib/dsl_compose/reader_base.rb', line 13

def dsl_name
  @dsl_name
end

#readerObject (readonly)

Returns the value of attribute reader.



14
15
16
# File 'lib/dsl_compose/reader_base.rb', line 14

def reader
  @reader
end