Class: Rouge::Theme::Style

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

Instance Method Summary collapse

Constructor Details

#initialize(theme, hsh = {}) ⇒ Style

Returns a new instance of Style.



38
39
40
41
42
# File 'lib/rouge/theme.rb', line 38

def initialize(theme, hsh={})
  super()
  @theme = theme
  merge!(hsh)
end

Instance Method Details

#render(selector) {|"#{selector} {"| ... } ⇒ Object

Yields:

  • ("#{selector} {")


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rouge/theme.rb', line 51

def render(selector, &b)
  return enum_for(:render, selector).to_a.join("\n") unless b

  return if empty?

  yield "#{selector} {"
  yield "  color: #{fg};" if fg
  yield "  background-color: #{bg};" if bg
  yield "  font-weight: bold;" if self[:bold]
  yield "  font-style: italic;" if self[:italic]
  yield "  text-decoration: underline;" if self[:underline]

  (self[:rules] || []).each do |rule|
    yield "  #{rule};"
  end

  yield "}"
end