Module: PryTheme::ThemeList

Extended by:
ThemeList
Included in:
ThemeList
Defined in:
lib/pry-theme/theme_list.rb

Instance Method Summary collapse

Instance Method Details

#activate_theme(name) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/pry-theme/theme_list.rb', line 22

def activate_theme(name)
  theme = themes.find { |t| t.name == name }

  if theme
    current_theme.disable if current_theme
    theme.activate
    true
  end
end

#activate_theme_intelligentlyObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pry-theme/theme_list.rb', line 32

def activate_theme_intelligently
  if Pry::Helpers::Platform.windows?
    activate_theme('pry-classic-16')
  else
    case PryTheme.tput_colors
    when 256 then activate_theme('pry-classic-256')
    when 16  then activate_theme('pry-classic-16')
    else          activate_theme('pry-classic-8')
    end
  end
end

#add_theme(theme) ⇒ Object



10
11
12
# File 'lib/pry-theme/theme_list.rb', line 10

def add_theme(theme)
  themes << theme
end

#current_themeObject



18
19
20
# File 'lib/pry-theme/theme_list.rb', line 18

def current_theme
  themes.find { |theme| theme.active? }
end

#each(&block) ⇒ Object



14
15
16
# File 'lib/pry-theme/theme_list.rb', line 14

def each(&block)
  themes.each(&block)
end

#reload_theme(name, file) ⇒ Object



44
45
46
47
48
49
# File 'lib/pry-theme/theme_list.rb', line 44

def reload_theme(name, file)
  @themes.delete_if { |theme| theme.name == name }
  load file
  activate_theme(name)
  true
end

#themesObject



6
7
8
# File 'lib/pry-theme/theme_list.rb', line 6

def themes
  @themes ||= []
end