class Nknm::List::Selector
Constants
- UnselectableItemsError
Attributes
items[R]
Public Class Methods
build(items)
click to toggle source
Build the desired selector for the specified items. @param items [Array, Nknm::List::Matches
] @return [Selector]
# File lib/nknm/list/selector.rb, line 11 def self.build(items) matches = if items.is_a?(Array) Nknm::List::Matches.new(items) elsif items.is_a?(Nknm::List::Matches) items end raise UnselectableItemsError if matches.nil? selector = matches.single? || matches.empty? ? Nknm::List::Selector : self selector.new(matches.items) end
new(items)
click to toggle source
# File lib/nknm/list/selector.rb, line 33 def initialize(items) @items = items end
Public Instance Methods
selection()
click to toggle source
Get the resolved selection from the items. @return [Object] the first item in the list
# File lib/nknm/list/selector.rb, line 27 def selection items.first end