Class: Confetti::Config
- Inherits:
-
Object
- Object
- Confetti::Config
- Extended by:
- TemplateHelper
- Includes:
- Helpers
- Defined in:
- lib/confetti/config.rb,
lib/confetti/config/feature.rb
Defined Under Namespace
Classes: Feature
Constant Summary collapse
- Author =
classes that represent child elements
Class.new Struct.new(:name, :href, :email)
- Name =
Class.new Struct.new(:name, :shortname)
- License =
Class.new Struct.new(:text, :href)
- Content =
Class.new Struct.new(:src, :type, :encoding)
- Icon =
Class.new Struct.new(:src, :height, :width)
- Preference =
Class.new Struct.new(:name, :value, :readonly)
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#description ⇒ Object
Returns the value of attribute description.
-
#feature_set ⇒ Object
readonly
Returns the value of attribute feature_set.
-
#height ⇒ Object
Returns the value of attribute height.
-
#icon_set ⇒ Object
readonly
Returns the value of attribute icon_set.
-
#license ⇒ Object
readonly
Returns the value of attribute license.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
Returns the value of attribute package.
-
#preference_set ⇒ Object
readonly
Returns the value of attribute preference_set.
-
#version ⇒ Object
Returns the value of attribute version.
-
#viewmodes ⇒ Object
readonly
Returns the value of attribute viewmodes.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Config
constructor
A new instance of Config.
- #populate_from_xml(xml_file) ⇒ Object
Methods included from TemplateHelper
Methods included from Helpers
Constructor Details
#initialize(*args) ⇒ Config
Returns a new instance of Config.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/confetti/config.rb', line 22 def initialize(*args) = Author.new @name = Name.new @license = License.new @content = Content.new @icon_set = TypedSet.new Icon @feature_set = TypedSet.new Feature @preference_set = TypedSet.new Preference @viewmodes = [] if args.length > 0 && is_file?(args.first) populate_from_xml args.first end end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def content @content end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/confetti/config.rb', line 6 def description @description end |
#feature_set ⇒ Object (readonly)
Returns the value of attribute feature_set.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def feature_set @feature_set end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/confetti/config.rb', line 6 def height @height end |
#icon_set ⇒ Object (readonly)
Returns the value of attribute icon_set.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def icon_set @icon_set end |
#license ⇒ Object (readonly)
Returns the value of attribute license.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def license @license end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def name @name end |
#package ⇒ Object
Returns the value of attribute package.
6 7 8 |
# File 'lib/confetti/config.rb', line 6 def package @package end |
#preference_set ⇒ Object (readonly)
Returns the value of attribute preference_set.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def preference_set @preference_set end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/confetti/config.rb', line 6 def version @version end |
#viewmodes ⇒ Object (readonly)
Returns the value of attribute viewmodes.
7 8 9 |
# File 'lib/confetti/config.rb', line 7 def viewmodes @viewmodes end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/confetti/config.rb', line 6 def width @width end |
Instance Method Details
#populate_from_xml(xml_file) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/confetti/config.rb', line 37 def populate_from_xml(xml_file) config_doc = REXML::Document.new(File.read(xml_file)).root fail "no doc parsed" unless config_doc @package = config_doc.attributes["id"] @version = config_doc.attributes["version"] config_doc.elements.each do |ele| case ele.name when "name" @name = Name.new(ele.text.strip, ele.attributes["shortname"]) when "author" = Author.new(ele.text.strip, ele.attributes["href"], ele.attributes["email"]) when "description" @description = ele.text.strip end end end |