Class: Buttonize::ButtonSet
- Inherits:
-
Object
- Object
- Buttonize::ButtonSet
- Defined in:
- lib/buttonize/button_set.rb
Instance Attribute Summary collapse
-
#buttons ⇒ Object
readonly
Returns the value of attribute buttons.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
- .current ⇒ Object
-
.define(options = {}) {|@@set| ... } ⇒ Object
Define a buttonset.
Instance Method Summary collapse
- #button(text, *opts) ⇒ Object
-
#generate(options) ⇒ Object
Generate all buttons recursively, all options set in define can be overruled here.
- #group(name, options = {}) {|group| ... } ⇒ Object
-
#initialize(options) ⇒ ButtonSet
constructor
A new instance of ButtonSet.
Constructor Details
#initialize(options) ⇒ ButtonSet
Returns a new instance of ButtonSet.
26 27 28 29 30 31 32 33 |
# File 'lib/buttonize/button_set.rb', line 26 def initialize() defaults = {:style_set => :default} @options = defaults.update() @buttons = [] @groups = [] @path = "" @parent = nil end |
Instance Attribute Details
#buttons ⇒ Object (readonly)
Returns the value of attribute buttons.
23 24 25 |
# File 'lib/buttonize/button_set.rb', line 23 def @buttons end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
23 24 25 |
# File 'lib/buttonize/button_set.rb', line 23 def groups @groups end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/buttonize/button_set.rb', line 23 def @options end |
#path ⇒ Object
Returns the value of attribute path.
24 25 26 |
# File 'lib/buttonize/button_set.rb', line 24 def path @path end |
Class Method Details
.current ⇒ Object
18 19 20 |
# File 'lib/buttonize/button_set.rb', line 18 def current @@set end |
.define(options = {}) {|@@set| ... } ⇒ Object
Define a buttonset
Options
- :style_file
-
The style definition file to load
- :style_set
-
The styleset to use, defaults to :default
- :target_path
-
The output directory
–
12 13 14 15 16 |
# File 'lib/buttonize/button_set.rb', line 12 def define(={},&block) @@set = self.new() yield @@set @@set end |
Instance Method Details
#button(text, *opts) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/buttonize/button_set.rb', line 43 def (text,*opts) = {:text => text, :options => {}} [:options] = opts.pop if opts.last.kind_of?(Hash) [:filename] = opts.pop if opts.last.kind_of?(String) @buttons << end |
#generate(options) ⇒ Object
Generate all buttons recursively, all options set in define can be overruled here. –
54 55 56 57 58 |
# File 'lib/buttonize/button_set.rb', line 54 def generate() # Don't run this when we're in cli mode return if Buttonize.cli? () end |
#group(name, options = {}) {|group| ... } ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/buttonize/button_set.rb', line 35 def group(name,={}) group = self.class.new({}.update(self.).update()) group.path = File.join(self.path,name) yield group @groups << group group end |