Class: Rouge::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/rouge/theme.rb

Direct Known Subclasses

CSSTheme

Defined Under Namespace

Classes: InheritableHash, Style

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(n) ⇒ Object



109
110
111
# File 'lib/rouge/theme.rb', line 109

def find(n)
  registry[n.to_s]
end

.name(n = nil) ⇒ Object



102
103
104
105
106
107
# File 'lib/rouge/theme.rb', line 102

def name(n=nil)
  return @name if n.nil?

  @name = n.to_s
  Theme.registry[@name] = self
end

.palette(arg = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rouge/theme.rb', line 70

def self.palette(arg={})
  @palette ||= InheritableHash.new(superclass.palette)

  if arg.is_a? Hash
    @palette.merge! arg
    @palette
  else
    case arg
    when /#[0-9a-f]+/i
      arg
    else
      @palette[arg] or raise "not in palette: #{arg.inspect}"
    end
  end
end

.registryObject



113
114
115
# File 'lib/rouge/theme.rb', line 113

def registry
  @registry ||= {}
end

.style(*tokens) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/rouge/theme.rb', line 92

def style(*tokens)
  style = tokens.last.is_a?(Hash) ? tokens.pop : {}

  style = Style.new(self, style)

  tokens.each do |tok|
    styles[tok.to_s] = style
  end
end

.stylesObject



87
88
89
# File 'lib/rouge/theme.rb', line 87

def self.styles
  @styles ||= InheritableHash.new(superclass.styles)
end

Instance Method Details

#stylesObject



65
66
67
# File 'lib/rouge/theme.rb', line 65

def styles
  @styles ||= self.class.styles.dup
end