Class: Vic::Colorscheme::Highlight::ArgumentSet
- Inherits:
-
Object
- Object
- Vic::Colorscheme::Highlight::ArgumentSet
- Includes:
- Enumerable
- Defined in:
- lib/vic/colorscheme/highlight/argument_set.rb
Instance Method Summary collapse
-
#add(argument) ⇒ Colorscheme::Highlight::ArgumentSet
Adds a new argument to the set.
- #arguments ⇒ Object
- #each ⇒ Object
-
#find_by_key(key) ⇒ Colorscheme::Highlight::Argument?
Finds an argument by a key.
-
#sort_by_key ⇒ Colorscheme::Highlight::ArgumentSet
Sorts the arguments by key name.
Instance Method Details
#add(argument) ⇒ Colorscheme::Highlight::ArgumentSet
Adds a new argument to the set
17 18 19 20 21 22 23 24 |
# File 'lib/vic/colorscheme/highlight/argument_set.rb', line 17 def add(argument) if argument.respond_to? :val arguments.push argument else # Raise an Exception raise TypeError.new("expted type Colorscheme::Highlight::Argument") end end |
#arguments ⇒ Object
5 6 7 |
# File 'lib/vic/colorscheme/highlight/argument_set.rb', line 5 def arguments @arguments ||= [] end |
#each ⇒ Object
9 10 11 |
# File 'lib/vic/colorscheme/highlight/argument_set.rb', line 9 def each arguments.each {|a| yield a } end |
#find_by_key(key) ⇒ Colorscheme::Highlight::Argument?
Finds an argument by a key.
30 31 32 |
# File 'lib/vic/colorscheme/highlight/argument_set.rb', line 30 def find_by_key(key) find {|a| a.key.to_s == key.to_s } end |
#sort_by_key ⇒ Colorscheme::Highlight::ArgumentSet
Sorts the arguments by key name
37 38 39 |
# File 'lib/vic/colorscheme/highlight/argument_set.rb', line 37 def sort_by_key sort {|a, b| a.key.to_s <=> b.key.to_s } end |