Class: Hairballs::Theme
- Inherits:
-
Object
- Object
- Hairballs::Theme
- Includes:
- LibraryHelpers
- Defined in:
- lib/hairballs/theme.rb
Overview
Themes primarily provide a means for customizing the look of your IRB prompt, although you’re at liberty to also do any other Ruby stuff you’d like, including load up common Hairballs::Plugins.
Unless you know you do, you probably don’t need to use this directly; Hairballs.add_theme() and Hairballs.use_theme() should cover most use cases.
Instance Attribute Summary collapse
-
#extend_bundler ⇒ Boolean
Tells Hairballs to do some hackery to let Themes use gems that aren’t specified in your app’s Gemfile.
-
#name ⇒ Symbol
Just an identifier for the Theme.
Instance Method Summary collapse
-
#initialize(name) ⇒ Theme
constructor
A new instance of Theme.
-
#irb_name ⇒ Symbol
The name of the Theme, but in the format that IRB.conf likes (an all-caps Symbol).
- #prompt(&block) ⇒ Hairballs::Prompt
-
#use! ⇒ Object
Tell IRB to use this Theme.
Methods included from LibraryHelpers
#do_bundler_extending, #find_latest_gem, #libraries, #require_libraries, #undo_bundler_extending
Constructor Details
#initialize(name) ⇒ Theme
Returns a new instance of Theme.
32 33 34 35 36 |
# File 'lib/hairballs/theme.rb', line 32 def initialize(name) @name = name @prompt = Prompt.new @extend_bundler = false end |
Instance Attribute Details
#extend_bundler ⇒ Boolean
Tells Hairballs to do some hackery to let Themes use gems that aren’t specified in your app’s Gemfile. This alleviates you from having to declare gems in your Gemfile simply for the sake of managing your personal IRB preferences.
29 30 31 |
# File 'lib/hairballs/theme.rb', line 29 def extend_bundler @extend_bundler end |
#name ⇒ Symbol
Just an identifier for the Theme. Don’t name two themes the same name–that will cause problems.
20 21 22 |
# File 'lib/hairballs/theme.rb', line 20 def name @name end |
Instance Method Details
#irb_name ⇒ Symbol
The name of the Theme, but in the format that IRB.conf likes (an all-caps Symbol).
51 52 53 |
# File 'lib/hairballs/theme.rb', line 51 def irb_name @name.to_s.upcase.to_sym end |
#prompt(&block) ⇒ Hairballs::Prompt
56 57 58 59 60 61 62 |
# File 'lib/hairballs/theme.rb', line 56 def prompt(&block) if block_given? @prompt_block = block else @prompt end end |
#use! ⇒ Object
Tell IRB to use this Theme.
39 40 41 42 43 44 45 |
# File 'lib/hairballs/theme.rb', line 39 def use! do_bundler_extending if @extend_bundler vputs "[th:#{@name}] Requiring libs..." require_libraries set_up_prompt vputs "[th:#{@name}] Done setting up." end |