Class: Palette::ColorScheme
- Inherits:
-
Object
- Object
- Palette::ColorScheme
show all
- Defined in:
- lib/palette/color_scheme.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(color_name) ⇒ ColorScheme
Returns a new instance of ColorScheme.
7
8
9
10
11
12
13
14
15
|
# File 'lib/palette/color_scheme.rb', line 7
def initialize(color_name)
@name = color_name
@notes = nil
@links = []
@rules = []
@reset = false
@background = nil
@author_name = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
34
35
36
|
# File 'lib/palette/color_scheme.rb', line 34
def method_missing(name, *args)
@rules << Palette::Rule.new(name.to_s, *args)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/palette/color_scheme.rb', line 5
def name
@name
end
|
Class Method Details
.run(name, block) ⇒ Object
124
125
126
127
128
|
# File 'lib/palette/color_scheme.rb', line 124
def self.run(name, block)
instance = new(name)
instance.instance_eval(&block)
instance.to_s
end
|
Instance Method Details
#author(author_name) ⇒ Object
17
18
19
|
# File 'lib/palette/color_scheme.rb', line 17
def author(author_name)
@author_name = author_name
end
|
#background(shade) ⇒ Object
29
30
31
32
|
# File 'lib/palette/color_scheme.rb', line 29
def background(shade)
return unless %w(light dark).include?(shade.to_s)
@background = shade.to_s
end
|
#color_scheme_name ⇒ Object
120
121
122
|
# File 'lib/palette/color_scheme.rb', line 120
def color_scheme_name
%{let colors_name="#{@name}"}
end
|
#generate_background ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'lib/palette/color_scheme.rb', line 111
def generate_background
return unless @background
%{
if has("gui_running")
set background=#{@background}
endif
}.strip
end
|
#generate_reset ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/palette/color_scheme.rb', line 99
def generate_reset
return unless @reset
%{
hi clear
if version > 580
if exists("syntax_on")
syntax reset
endif
endif
}.strip
end
|
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/palette/color_scheme.rb', line 88
def
%{
" Vim color file
" This file was generated by Palette
" http://rubygems.org/gems/palette
"
" Author: #{@author_name}
#{%{" Notes: #{@notes}} if @notes}
}.strip
end
|
#link(*args) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/palette/color_scheme.rb', line 80
def link(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
args.each do |arg|
@links << Link.new(arg, options[:to])
end
end
|
#none ⇒ Object
60
61
62
|
# File 'lib/palette/color_scheme.rb', line 60
def none
"NONE"
end
|
#notes(notes) ⇒ Object
21
22
23
|
# File 'lib/palette/color_scheme.rb', line 21
def notes(notes)
@notes = notes
end
|
#reset(reset) ⇒ Object
25
26
27
|
# File 'lib/palette/color_scheme.rb', line 25
def reset(reset)
@reset = !!reset
end
|
#to_s ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/palette/color_scheme.rb', line 64
def to_s
output = []
output <<
output << ""
output << generate_reset
output << ""
output << color_scheme_name
output << ""
output << generate_background
output << ""
output << @rules
output << ""
output << @links
output.compact.join("\n")
end
|