Class: Ramaze::Option::DSL
Instance Attribute Summary collapse
-
#holder ⇒ Object
readonly
Returns the value of attribute holder.
Instance Method Summary collapse
-
#initialize(holder, &block) ⇒ DSL
constructor
A new instance of DSL.
- #o(doc, key, value, options = {}) ⇒ Object
-
#output ⇒ Object
to generate a new sorted source file from the config, was only used to merge new and old DSL.
Constructor Details
#initialize(holder, &block) ⇒ DSL
Returns a new instance of DSL.
9 10 11 12 13 |
# File 'lib/ramaze/option/dsl.rb', line 9 def initialize(holder, &block) @holder = holder @config = {} instance_eval(&block) if block_given? end |
Instance Attribute Details
#holder ⇒ Object (readonly)
Returns the value of attribute holder.
7 8 9 |
# File 'lib/ramaze/option/dsl.rb', line 7 def holder @holder end |
Instance Method Details
#o(doc, key, value, options = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ramaze/option/dsl.rb', line 15 def o(doc, key, value, = {}) @config[key] = [doc, value, ] holder.add_option(key, value, complain = false) holder.trait[key] = .merge(:doc => doc) end |
#output ⇒ Object
to generate a new sorted source file from the config, was only used to merge new and old DSL.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ramaze/option/dsl.rb', line 24 def output @config.keys.sort_by{|k,v| k.to_s }.each do |key| doc, value, = @config[key] puts "o %s," % doc.dump if .empty? puts " %p, %p" % [key, value] else format = .map{|(k,v)| '%p => %p' % [k,v]}.join(', ') puts " %p, %p, %s" % [key, value, format] end puts end end |