Class: Reality::Country::List
- Inherits:
-
Object
- Object
- Reality::Country::List
- Includes:
- Enumerable
- Defined in:
- lib/reality/country.rb
Instance Method Summary collapse
- #count ⇒ Object
- #each(&block) ⇒ Object
- #first(n = nil) ⇒ Object
-
#initialize(*names) ⇒ List
constructor
A new instance of List.
- #last(n = nil) ⇒ Object
- #sample(n = nil) ⇒ Object
- #to_a ⇒ Object
- #where(**filters) ⇒ Object
Constructor Details
#initialize(*names) ⇒ List
Returns a new instance of List.
7 8 9 |
# File 'lib/reality/country.rb', line 7 def initialize(*names) @names = names end |
Instance Method Details
#count ⇒ Object
11 12 13 |
# File 'lib/reality/country.rb', line 11 def count @names.count end |
#each(&block) ⇒ Object
30 31 32 33 |
# File 'lib/reality/country.rb', line 30 def each(&block) @pages = get(*@names) @pages.each(&block) end |
#first(n = nil) ⇒ Object
15 16 17 18 |
# File 'lib/reality/country.rb', line 15 def first(n = nil) res = get(*@names.first(n || 1)) n ? res : res.first end |
#last(n = nil) ⇒ Object
20 21 22 23 |
# File 'lib/reality/country.rb', line 20 def last(n = nil) res = get(*@names.last(n || 1)) n ? res : res.first end |
#sample(n = nil) ⇒ Object
25 26 27 28 |
# File 'lib/reality/country.rb', line 25 def sample(n = nil) res = get(*@names.sample(n || 1)) n ? res : res.first end |
#to_a ⇒ Object
37 38 39 |
# File 'lib/reality/country.rb', line 37 def to_a get(*@names) end |