Sha256: e8ffe82e7382404adfc6a7aac4b9ed561aaf670c4612490a10225be09cab67a8

Contents?: true

Size: 491 Bytes

Versions: 4

Compression:

Stored size: 491 Bytes

Contents

module ThousandIsland
  # 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
  class StyleHash < Hash
    def initialize(style={})
      super()
      self.merge!(style)
    end

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

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thousand_island-0.1.2 lib/thousand_island/utilities/style_hash.rb
thousand_island-0.1.1 lib/thousand_island/utilities/style_hash.rb
thousand_island-0.1.0 lib/thousand_island/utilities/style_hash.rb
thousand_island-0.0.1 lib/thousand_island/utilities/style_hash.rb