Class: StyleFormat
- Inherits:
-
Object
- Object
- StyleFormat
- Defined in:
- lib/surpass/style.rb
Instance Attribute Summary collapse
-
#alignment ⇒ Object
Returns the value of attribute alignment.
-
#borders ⇒ Object
Returns the value of attribute borders.
-
#font ⇒ Object
Returns the value of attribute font.
-
#number_format_string ⇒ Object
Returns the value of attribute number_format_string.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#protection ⇒ Object
Returns the value of attribute protection.
Instance Method Summary collapse
- #hash_select(hash, pattern) ⇒ Object
-
#initialize(hash = {}) ⇒ StyleFormat
constructor
A new instance of StyleFormat.
Constructor Details
#initialize(hash = {}) ⇒ StyleFormat
Returns a new instance of StyleFormat.
9 10 11 12 13 14 15 16 17 |
# File 'lib/surpass/style.rb', line 9 def initialize(hash = {}) @number_format_string = hash[:number_format_string] || 'General' @font = Font.new(hash_select(hash, /^font_/)) @alignment = Alignment.new(hash_select(hash, /^text_/)) @borders = Borders.new(hash_select(hash, /^border_/)) @pattern = Pattern.new(hash_select(hash, /^(fill|pattern)_/)) @protection = Protection.new end |
Instance Attribute Details
#alignment ⇒ Object
Returns the value of attribute alignment.
4 5 6 |
# File 'lib/surpass/style.rb', line 4 def alignment @alignment end |
#borders ⇒ Object
Returns the value of attribute borders.
5 6 7 |
# File 'lib/surpass/style.rb', line 5 def borders @borders end |
#font ⇒ Object
Returns the value of attribute font.
3 4 5 |
# File 'lib/surpass/style.rb', line 3 def font @font end |
#number_format_string ⇒ Object
Returns the value of attribute number_format_string.
2 3 4 |
# File 'lib/surpass/style.rb', line 2 def number_format_string @number_format_string end |
#pattern ⇒ Object
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/surpass/style.rb', line 6 def pattern @pattern end |
#protection ⇒ Object
Returns the value of attribute protection.
7 8 9 |
# File 'lib/surpass/style.rb', line 7 def protection @protection end |
Instance Method Details
#hash_select(hash, pattern) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/surpass/style.rb', line 19 def hash_select(hash, pattern) new_hash = {} hash.keys.each do |k| next unless k.to_s =~ pattern new_key = k.to_s.gsub(pattern, '').to_sym new_hash[new_key] = hash[k] end new_hash end |