Sha256: 044f6f87a3215f77c9eb7c11008a59c53c3dd40f7d17f9feed52750be3ca84bd

Contents?: true

Size: 919 Bytes

Versions: 10

Compression:

Stored size: 919 Bytes

Contents

module Bhf

  class Settings

    def initialize(options)
      @options = options
    end

    def pages
      @options['pages'].each_with_object([]) do |page, obj|
        if page.is_a?(String)
          page = {page => nil}
        end
        obj << page.keys[0]
      end
    end

    def content_for_page(selected_page)
      @options['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

    def find_platform(platform_name, current_account = nil)
      # TODO: error for platforms whit the same name
      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

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bhf-0.6.22 lib/bhf/settings.rb
bhf-0.6.21 lib/bhf/settings.rb
bhf-0.6.20 lib/bhf/settings.rb
bhf-0.6.15 lib/bhf/settings.rb
bhf-0.6.14 lib/bhf/settings.rb
bhf-0.6.13 lib/bhf/settings.rb
bhf-0.6.12 lib/bhf/settings.rb
bhf-0.6.11 lib/bhf/settings.rb
bhf-0.6.10 lib/bhf/settings.rb
bhf-0.6.6 lib/bhf/settings.rb