Class: ThousandIsland::StyleHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/thousand_island/utilities/style_hash.rb

Overview

A subclass of Hash, automatically adds keys that mirror other keys to allow for a couple of small differences in the Prawn options hashes:

:font_style = :style
:styles = :style and puts it into an Array

Instance Method Summary collapse

Constructor Details

#initialize(style = {}) ⇒ StyleHash

Returns a new instance of StyleHash.



7
8
9
10
# File 'lib/thousand_island/utilities/style_hash.rb', line 7

def initialize(style={})
  super()
  self.merge!(style)
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
15
16
# File 'lib/thousand_island/utilities/style_hash.rb', line 12

def [](key)
  return self[:size] if key == :font_size
  return [self[:style]] if key == :styles
  super
end