Class: Coloration::Readers::ItemsLookup
- Defined in:
- lib/coloration/readers/textmate_theme_reader.rb
Instance Method Summary collapse
- #[](keys) ⇒ Object
-
#initialize(items) ⇒ ItemsLookup
constructor
A new instance of ItemsLookup.
Constructor Details
#initialize(items) ⇒ ItemsLookup
Returns a new instance of ItemsLookup.
53 54 55 56 |
# File 'lib/coloration/readers/textmate_theme_reader.rb', line 53 def initialize(items) @items = items @score_manager = Textpow::ScoreManager.new end |
Instance Method Details
#[](keys) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/coloration/readers/textmate_theme_reader.rb', line 58 def [](keys) keys.split(",").each do |key| best_selector = nil best_score = 0 @items.keys.each do |selector| score = @score_manager.score(selector, key) if score > best_score best_score, best_selector = score, selector end end if best_selector return @items[best_selector] end end nil end |