class Rugments::Theme::Style

Public Class Methods

new(theme, hsh = {}) click to toggle source
Calls superclass method
# File lib/rugments/theme.rb, line 6
def initialize(theme, hsh = {})
  super()
  @theme = theme
  merge!(hsh)
end

Public Instance Methods

render(selector) { |"| ... } click to toggle source
# File lib/rugments/theme.rb, line 19
def render(selector, &b)
  return enum_for(:render, selector).to_a.join("\n") unless b

  return if empty?

  yield "#{selector} {"
  rendered_rules.each do |rule|
    yield "  #{rule};"
  end
  yield '}'
end
rendered_rules() { |"color:| ... } click to toggle source
# File lib/rugments/theme.rb, line 31
def rendered_rules(&b)
  return enum_for(:rendered_rules) unless b
  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(&b)
end