Module: Rouge::HasModes

Included in:
Themes::Base16, Themes::Gruvbox
Defined in:
lib/rouge/theme.rb

Instance Method Summary collapse

Instance Method Details

#get_mode(mode) ⇒ Object


140
141
142
143
144
145
# File 'lib/rouge/theme.rb', line 140

def get_mode(mode)
  return self if self.mode == mode

  new_name = "#{self.name}.#{mode}"
  Class.new(self) { name(new_name); set_mode!(mode) }
end

#mode(arg = :absent) ⇒ Object


133
134
135
136
137
138
# File 'lib/rouge/theme.rb', line 133

def mode(arg=:absent)
  return @mode if arg == :absent

  @modes ||= {}
  @modes[arg] ||= get_mode(arg)
end

#mode!(arg) ⇒ Object


152
153
154
155
156
# File 'lib/rouge/theme.rb', line 152

def mode!(arg)
  alt_name = "#{self.name}.#{arg}"
  register(alt_name)
  set_mode!(arg)
end

#set_mode!(mode) ⇒ Object


147
148
149
150
# File 'lib/rouge/theme.rb', line 147

def set_mode!(mode)
  @mode = mode
  send("make_#{mode}!")
end