Sha256: 50d7bf7af8996a6297cc965212f0c45d5f24bbe46eab180e89f22513efad3dbb

Contents?: true

Size: 1.56 KB

Versions: 10

Compression:

Stored size: 1.56 KB

Contents

module Views
  module Why
    module ExampleList
      EXAMPLES = begin
        out = [
          { :subpath => 'a_simple_helper', :title => 'A Simple Helper' },
          { :subpath => 'a_larger_view', :title => 'A Larger View' },
          { :subpath => 'commonality_and_inheritance', :title => 'Commonality and Inheritance' },
          { :subpath => 'building_a_rich_modal_dialog', :title => 'Building a Rich Modal Dialog' }
        ]
        out.each_with_index do |hash, index|
          hash[:number] = (index + 1)
          hash[:path] = "/why/#{hash[:subpath]}.html"
        end
        out
      end

      def first_example
        EXAMPLES[0]
      end

      def number_of_examples
        EXAMPLES.length
      end

      def this_example_number
        this_example[:number] if this_example
      end

      def example_by_number(number)
        EXAMPLES.detect { |e| e[:number] == number }
      end

      def this_example
        @this_example ||= begin
          request_path = request[:path]
          request_path = "/#{request_path}" unless request_path.start_with?("/")

          out = EXAMPLES.detect { |e| e[:path] == request_path }
          out || :none
        end
        @this_example unless @this_example == :none
      end

      def example_title(example)
        "Example #{example[:number]}. #{example[:title]}"
      end

      def next_example
        @next_example ||= begin
          if this_example_number
            example_by_number(this_example_number + 1)
          else
            first_example
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fortitude-0.9.6-java doc/source/why/example_list.rb
fortitude-0.9.6 doc/source/why/example_list.rb
fortitude-0.9.5-java doc/source/why/example_list.rb
fortitude-0.9.5 doc/source/why/example_list.rb
fortitude-0.9.4-java doc/source/why/example_list.rb
fortitude-0.9.4 doc/source/why/example_list.rb
fortitude-0.9.3-java doc/source/why/example_list.rb
fortitude-0.9.3 doc/source/why/example_list.rb
fortitude-0.9.2-java doc/source/why/example_list.rb
fortitude-0.9.2 doc/source/why/example_list.rb