Class: Hipmost::Hipchat::RoomRepository
- Inherits:
-
Object
- Object
- Hipmost::Hipchat::RoomRepository
- Extended by:
- Forwardable
- Defined in:
- lib/hipmost/hipchat/room_repository.rb
Instance Attribute Summary collapse
-
#name_index ⇒ Object
Returns the value of attribute name_index.
-
#rooms ⇒ Object
Returns the value of attribute rooms.
Class Method Summary collapse
Instance Method Summary collapse
- #file_data ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(path) ⇒ RoomRepository
constructor
A new instance of RoomRepository.
- #load(data = file_data) ⇒ Object
Constructor Details
#initialize(path) ⇒ RoomRepository
Returns a new instance of RoomRepository.
17 18 19 20 21 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 17 def initialize(path) @path = Pathname.new(path).join("rooms.json") @rooms = {} @name_index = {} end |
Instance Attribute Details
#name_index ⇒ Object
Returns the value of attribute name_index.
8 9 10 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 8 def name_index @name_index end |
#rooms ⇒ Object
Returns the value of attribute rooms.
8 9 10 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 8 def rooms @rooms end |
Class Method Details
.load_from(path) ⇒ Object
13 14 15 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 13 def self.load_from(path) new(path).tap(&:load) end |
Instance Method Details
#file_data ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 37 def file_data if File.exists? @path File.read(@path) else abort "./data does not exist; did you forget to specify a path to the data?" end end |
#find_by_name(name) ⇒ Object
33 34 35 |
# File 'lib/hipmost/hipchat/room_repository.rb', line 33 def find_by_name(name) self[name_index[name]] end |