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
|
# File 'lib/palette/color_scheme.rb', line 7
def initialize(color_name)
@name = color_name
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
28
29
30
31
|
# File 'lib/palette/color_scheme.rb', line 28
def method_missing(name, *args)
@rules ||= []
@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
117
118
119
120
121
|
# File 'lib/palette/color_scheme.rb', line 117
def self.run(name, block)
instance = new(name)
instance.instance_eval(&block)
instance.to_s
end
|
Instance Method Details
#author(author_name) ⇒ Object
11
12
13
|
# File 'lib/palette/color_scheme.rb', line 11
def author(author_name)
@author_name = author_name
end
|
#background(shade) ⇒ Object
23
24
25
26
|
# File 'lib/palette/color_scheme.rb', line 23
def background(shade)
return unless %w(light dark).include?(shade.to_s)
@background = shade.to_s
end
|
#color_scheme_name ⇒ Object
113
114
115
|
# File 'lib/palette/color_scheme.rb', line 113
def color_scheme_name
%{let colors_name="#{@name}"}
end
|
#generate_background ⇒ Object
104
105
106
107
108
109
110
111
|
# File 'lib/palette/color_scheme.rb', line 104
def generate_background
return unless @background
%{
if has("gui_running")
set background=#{@background}
endif
}.strip
end
|
#generate_reset ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/palette/color_scheme.rb', line 92
def generate_reset
return unless @reset
%{
hi clear
if version > 580
if exists("syntax_on")
syntax reset
endif
endif
}.strip
end
|
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/palette/color_scheme.rb', line 81
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
72
73
74
75
76
77
78
79
|
# File 'lib/palette/color_scheme.rb', line 72
def link(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
@links ||= []
args.each do |arg|
@links << Link.new(arg, options[:to])
end
end
|
#notes(notes) ⇒ Object
15
16
17
|
# File 'lib/palette/color_scheme.rb', line 15
def notes(notes)
@notes = notes
end
|
#reset(reset) ⇒ Object
19
20
21
|
# File 'lib/palette/color_scheme.rb', line 19
def reset(reset)
@reset = !!reset
end
|
#to_s ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/palette/color_scheme.rb', line 56
def to_s
output = []
output <<
output << ""
output << color_scheme_name
output << ""
output << generate_reset
output << ""
output << generate_background
output << ""
output << @rules
output << ""
output << @links
output.compact.join("\n")
end
|