Parent

Prawn::Chart::Themes::Theme

Attributes

background_colour[RW]
colours[RW]
font_colour[RW]
marker_colour[RW]
name[RW]
title[RW]

Public Class Methods

new(theme_hash) click to toggle source

Creates a new theme from a theme hash. The hash comes from the library parsing YAML definitions of a theme.

# File lib/prawn/graph/themes.rb, line 62
def initialize(theme_hash)
  @name = theme_hash['name']
  @title = theme_hash['title']

  if theme_hash.keys.include?('colours') 
    @colours = theme_hash['colours']        
  elsif theme_hash.keys.include?('colors')
    @colours = theme_hash['colors']        
  end

  if theme_hash.keys.include?('font_colour') 
    @font_colour = theme_hash['font_colour']        
  elsif theme_hash.keys.include?('font_color')
    @font_colour = theme_hash['font_color']        
  end

  if theme_hash.keys.include?('background_colour') 
    @background_colour = theme_hash['background_colour']        
  elsif theme_hash.keys.include?('background_color')
    @background_colour = theme_hash['background_color']        
  end

  if theme_hash.keys.include?('marker_colour') 
    @marker_colour = theme_hash['marker_colour']        
  elsif theme_hash.keys.include?('marker_color')
    @marker_colour = theme_hash['marker_color']        
  end

  @stroke_grid_markers = theme_hash['stroke_grid_markers'].to_i
end

Public Instance Methods

next_color() click to toggle source
Alias for: next_colour
next_colour() click to toggle source

Returns the next colour in the array of colours associated with this theme. If it gets to the end, it starts again from the beginning.

# File lib/prawn/graph/themes.rb, line 97
def next_colour
  unless @current_colour
    @current_colour = 0
    return @colours[0]
  end
  @current_colour += 1
  @current_colour = 0 if @current_colour == @colours.nitems
  @colours[@current_colour]
end
Also aliased as: next_color
stroke_grid_markers?() click to toggle source
# File lib/prawn/graph/themes.rb, line 108
def stroke_grid_markers?
  @stroke_grid_markers == 1
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.