Class: Bhf::Settings
- Inherits:
-
Object
- Object
- Bhf::Settings
- Defined in:
- lib/bhf/settings.rb
Instance Method Summary collapse
- #content_for_page(selected_page) ⇒ Object
- #find_platform(platform_name, current_account = nil) ⇒ Object
-
#initialize(options) ⇒ Settings
constructor
A new instance of Settings.
- #pages ⇒ Object
Constructor Details
#initialize(options) ⇒ Settings
Returns a new instance of Settings.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bhf/settings.rb', line 5 def initialize() = t = pages.each_with_object([]) do |page, obj| content_for_page(page).each do |platform| obj << platform.keys.flatten end end.flatten! if t.uniq.length != t.length raise Exception.new("Platforms with identical names: '#{t.detect{ |e| t.count(e) > 1 }}'") end end |
Instance Method Details
#content_for_page(selected_page) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bhf/settings.rb', line 28 def content_for_page(selected_page) ['pages'].each do |page| page = {page => nil} if page.is_a?(String) if selected_page == page.keys[0] return page.values.flatten end end nil end |
#find_platform(platform_name, current_account = nil) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/bhf/settings.rb', line 39 def find_platform(platform_name, current_account = nil) pages.each do |page| content_for_page(page).each do |platform| bhf_platform = Bhf::Platform.new(platform, page, current_account) return bhf_platform if bhf_platform.name == platform_name end end end |
#pages ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/bhf/settings.rb', line 18 def pages return @pages if @pages @pages = ['pages'].each_with_object([]) do |page, obj| if page.is_a?(String) page = {page => nil} end obj << page.keys[0] end end |