Class: Iterm2mintty::Iterm2ThemeParser
- Inherits:
-
Object
- Object
- Iterm2mintty::Iterm2ThemeParser
- Defined in:
- lib/iterm2mintty/iterm2_theme_parser.rb
Instance Attribute Summary collapse
-
#itermcolors ⇒ Object
readonly
Returns the value of attribute itermcolors.
Instance Method Summary collapse
- #blue(value) ⇒ Object
- #build ⇒ Object
- #green(value) ⇒ Object
-
#initialize(itermcolors) ⇒ Iterm2ThemeParser
constructor
A new instance of Iterm2ThemeParser.
- #parsed_theme ⇒ Object
- #red(value) ⇒ Object
Constructor Details
#initialize(itermcolors) ⇒ Iterm2ThemeParser
Returns a new instance of Iterm2ThemeParser.
8 9 10 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 8 def initialize(itermcolors) @itermcolors = itermcolors end |
Instance Attribute Details
#itermcolors ⇒ Object (readonly)
Returns the value of attribute itermcolors.
6 7 8 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 6 def itermcolors @itermcolors end |
Instance Method Details
#blue(value) ⇒ Object
38 39 40 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 38 def blue(value) Integer(value.fetch("Blue Component").to_f * 255) end |
#build ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 12 def build parsed_theme.map do |k, v| case k when /Ansi (\d+) Color/ ThemeComponent.ansi(Integer($1)) when "Background Color" BGColorComponent when "Foreground Color" FGColorComponent when "Cursor Color" CursorColorComponent else # TODO(bobcats): Probably good candidate for NullComponent next end.new(red(v), green(v), blue(v)) end.compact end |
#green(value) ⇒ Object
34 35 36 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 34 def green(value) Integer(value.fetch("Green Component").to_f * 255) end |
#parsed_theme ⇒ Object
42 43 44 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 42 def parsed_theme Plist.parse_xml(itermcolors) end |
#red(value) ⇒ Object
30 31 32 |
# File 'lib/iterm2mintty/iterm2_theme_parser.rb', line 30 def red(value) Integer(value.fetch("Red Component").to_f * 255) end |