Class: Bgg::Plays
- Inherits:
-
Object
- Object
- Bgg::Plays
- Defined in:
- lib/bgg/plays.rb,
lib/bgg/plays_iterator.rb
Defined Under Namespace
Classes: Iterator
Class Method Summary collapse
Class Method Details
.find_by_id(game_id) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/bgg/plays.rb', line 19 def self.find_by_id(game_id) game_id = Integer(game_id) if game_id < 1 raise ArgumentError.new('game_id must be greater than 0!') end end |
.find_by_username(username) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bgg/plays.rb', line 3 def self.find_by_username(username) if username =~ /^\d*$/ # this is a sorta hokey restriction because there is probably nothing requiring # users to have non-numeric usernames. I'm not sure that I've seen one though. raise ArgumentError.new('username must not be empty or only digits!') end if username.is_a?(Integer) raise ArgumentError.new('username must not be an Integer!') end iterator = Bgg::Plays::Iterator.new(username) iterator.nil? ? nil : iterator end |