annlat 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
 - data/.gitignore +22 -0
 - data/Gemfile +7 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +29 -0
 - data/Rakefile +2 -0
 - data/annlat.gemspec +23 -0
 - data/lib/annlat.rb +9 -0
 - data/lib/annlat/AnnLat.rb +235 -0
 - data/lib/annlat/Concept.rb +39 -0
 - data/lib/annlat/LaRuby.rb +288 -0
 - data/lib/annlat/Sundries.rb +72 -0
 - data/lib/annlat/version.rb +3 -0
 - metadata +70 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                ZWM2MzMyZTlkMWVkZTNlYWZlNDJhMDBhNjZjMTM2Nzg0OGYxN2I4OQ==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                OGZiMjM5MDg3ZTMzNWExZDcyNjZjMjMyOWZkMTM4ODIyNzFmMjM0MA==
         
     | 
| 
      
 7 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                MWVlYzM0MzAyYzQ1YjkzMjQ3YTZiMThjNzFhNGY1MmUzZjY4ZmNhZGFjNmM4
         
     | 
| 
      
 10 
     | 
    
         
            +
                N2RhOGJiNTQ5NDg5MDU4Y2UyNjk3YzI5NWY3ZDliODk3Zjk1YWVmODVkNjEx
         
     | 
| 
      
 11 
     | 
    
         
            +
                NTc2YTA5YTFhODhjMzgwOWVjZTcwNGZmMzU1MWNmMGYyNmZjM2Y=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                MDdjYzljZGNjMWFhNmI5ODdjYmZjNzFmOWZhNmNiZGJkYTBhNzRlMjhlMzVl
         
     | 
| 
      
 14 
     | 
    
         
            +
                MmEzOGVkMDNkMjM0NmVkMTc0NGY0MWM5NDM1MzVmNzg4ZGIyYzFlMjNmNzZk
         
     | 
| 
      
 15 
     | 
    
         
            +
                MzJiNDBiNTY3YTcxMTkxMjU1NzlhNjEzNjJhMDBkN2MwZTM4ZDY=
         
     | 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            *.gem
         
     | 
| 
      
 2 
     | 
    
         
            +
            *.rbc
         
     | 
| 
      
 3 
     | 
    
         
            +
            .bundle
         
     | 
| 
      
 4 
     | 
    
         
            +
            .config
         
     | 
| 
      
 5 
     | 
    
         
            +
            .yardoc
         
     | 
| 
      
 6 
     | 
    
         
            +
            Gemfile.lock
         
     | 
| 
      
 7 
     | 
    
         
            +
            InstalledFiles
         
     | 
| 
      
 8 
     | 
    
         
            +
            _yardoc
         
     | 
| 
      
 9 
     | 
    
         
            +
            coverage
         
     | 
| 
      
 10 
     | 
    
         
            +
            doc/
         
     | 
| 
      
 11 
     | 
    
         
            +
            lib/bundler/man
         
     | 
| 
      
 12 
     | 
    
         
            +
            pkg
         
     | 
| 
      
 13 
     | 
    
         
            +
            rdoc
         
     | 
| 
      
 14 
     | 
    
         
            +
            spec/reports
         
     | 
| 
      
 15 
     | 
    
         
            +
            test/tmp
         
     | 
| 
      
 16 
     | 
    
         
            +
            test/version_tmp
         
     | 
| 
      
 17 
     | 
    
         
            +
            tmp
         
     | 
| 
      
 18 
     | 
    
         
            +
            *.bundle
         
     | 
| 
      
 19 
     | 
    
         
            +
            *.so
         
     | 
| 
      
 20 
     | 
    
         
            +
            *.o
         
     | 
| 
      
 21 
     | 
    
         
            +
            *.a
         
     | 
| 
      
 22 
     | 
    
         
            +
            mkmf.log
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Alexander Shevtsov
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Annlat
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            TODO: Write a gem description
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                gem 'annlat'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ gem install annlat
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            TODO: Write usage instructions here
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            1. Fork it ( https://github.com/[my-github-username]/annlat/fork )
         
     | 
| 
      
 26 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 27 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 28 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 29 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/annlat.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'annlat/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "annlat"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Annlat::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Alexander Shevtsov"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["randomlogin76@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = "Learnleague gem for containg used libraries"
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = ''
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = ""
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.6"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/annlat.rb
    ADDED
    
    
| 
         @@ -0,0 +1,235 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # The class AnnLat, short for AnnotatedLatex, allows a concept to create 
         
     | 
| 
      
 2 
     | 
    
         
            +
            # step-by-step solutions with text, latex, hints, more hints, and embedded prerequisite concepts. 
         
     | 
| 
      
 3 
     | 
    
         
            +
            # It also allows for the creation of questions with text, latex, hints, and suggestions.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # The communication between the engine and the concepts is faciliated by AnnLat 
         
     | 
| 
      
 5 
     | 
    
         
            +
            # by the agreement that all communication from a concept back to the engine that is intended
         
     | 
| 
      
 6 
     | 
    
         
            +
            # to be displayed to the user is an AnnLat object.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # An instance object maintains an array of objects to be presented on the screen together
         
     | 
| 
      
 9 
     | 
    
         
            +
            # with an array indicating the type of each object. The engine can then access both arrays 
         
     | 
| 
      
 10 
     | 
    
         
            +
            # and decide how to encode each object, and which ones to present on the screen.
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'securerandom'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            public
         
     | 
| 
      
 16 
     | 
    
         
            +
            def my_json
         
     | 
| 
      
 17 
     | 
    
         
            +
              self.to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            def get_type(thing)
         
     | 
| 
      
 21 
     | 
    
         
            +
              if thing.class.ancestors.include? Concept
         
     | 
| 
      
 22 
     | 
    
         
            +
                :Concept
         
     | 
| 
      
 23 
     | 
    
         
            +
              elsif thing.class.ancestors.include? Latex
         
     | 
| 
      
 24 
     | 
    
         
            +
                :Latex
         
     | 
| 
      
 25 
     | 
    
         
            +
              elsif thing.class.ancestors.include? AnnLat
         
     | 
| 
      
 26 
     | 
    
         
            +
                :AnnLat
         
     | 
| 
      
 27 
     | 
    
         
            +
              else
         
     | 
| 
      
 28 
     | 
    
         
            +
                thing.class.to_s.to_sym
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            def which_types(stuff)
         
     | 
| 
      
 33 
     | 
    
         
            +
              subtypes = []
         
     | 
| 
      
 34 
     | 
    
         
            +
              stuff.each do |stuffoid|
         
     | 
| 
      
 35 
     | 
    
         
            +
                subtypes.insert(-1, get_type(stuffoid))
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
              subtypes
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            class AnnLat #just the scafolds, the idea is to implement this so it will support the example concepts
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              attr_accessor :objects, :tags, :options
         
     | 
| 
      
 45 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 46 
     | 
    
         
            +
                @objects = []
         
     | 
| 
      
 47 
     | 
    
         
            +
                @tags = []
         
     | 
| 
      
 48 
     | 
    
         
            +
                @options = {}
         
     | 
| 
      
 49 
     | 
    
         
            +
              end 
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def each_with_symbols
         
     | 
| 
      
 52 
     | 
    
         
            +
                @objects.each_with_index do |x,i|
         
     | 
| 
      
 53 
     | 
    
         
            +
                  yield(@objects[i][0],@tags[i][0])
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def each
         
     | 
| 
      
 58 
     | 
    
         
            +
                @objects.each {|x| yield(x)}
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              def +(x)
         
     | 
| 
      
 62 
     | 
    
         
            +
                out=AnnLat.new
         
     | 
| 
      
 63 
     | 
    
         
            +
                out.objects=self.objects+x.objects
         
     | 
| 
      
 64 
     | 
    
         
            +
                out.tags=self.tags+x.tags
         
     | 
| 
      
 65 
     | 
    
         
            +
                out
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              def add(*stuff) # adds stuff to the @objects array, in sequential order. 
         
     | 
| 
      
 69 
     | 
    
         
            +
                arr1=[]
         
     | 
| 
      
 70 
     | 
    
         
            +
                arr2=[]
         
     | 
| 
      
 71 
     | 
    
         
            +
                stuff.flatten.each do |object|
         
     | 
| 
      
 72 
     | 
    
         
            +
                  case get_type(object)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  when :Table
         
     | 
| 
      
 74 
     | 
    
         
            +
                    hash = {}
         
     | 
| 
      
 75 
     | 
    
         
            +
                    hash[:objects]=object.objects
         
     | 
| 
      
 76 
     | 
    
         
            +
                    hash[:types]=object.types
         
     | 
| 
      
 77 
     | 
    
         
            +
                    arr1 << hash
         
     | 
| 
      
 78 
     | 
    
         
            +
                    arr2 << :Table
         
     | 
| 
      
 79 
     | 
    
         
            +
                  #when :Image
         
     | 
| 
      
 80 
     | 
    
         
            +
                  #  str = object.path
         
     | 
| 
      
 81 
     | 
    
         
            +
                  #  arr1 << str
         
     | 
| 
      
 82 
     | 
    
         
            +
                  #  arr2 << get_type(object)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  else
         
     | 
| 
      
 84 
     | 
    
         
            +
                    arr1 << object
         
     | 
| 
      
 85 
     | 
    
         
            +
                    arr2 << get_type(object)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
                @objects << arr1
         
     | 
| 
      
 90 
     | 
    
         
            +
                @tags << arr2
         
     | 
| 
      
 91 
     | 
    
         
            +
                self
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              #hint is new AnnLat object that is passed with tag :Hint
         
     | 
| 
      
 95 
     | 
    
         
            +
              def addHint(*stuff)
         
     | 
| 
      
 96 
     | 
    
         
            +
                x=AnnLat.new
         
     | 
| 
      
 97 
     | 
    
         
            +
                x.add(*stuff)
         
     | 
| 
      
 98 
     | 
    
         
            +
                @objects << [x]
         
     | 
| 
      
 99 
     | 
    
         
            +
                @tags << [:Hint]
         
     | 
| 
      
 100 
     | 
    
         
            +
                self
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 104 
     | 
    
         
            +
                output={} 
         
     | 
| 
      
 105 
     | 
    
         
            +
                obs=[]
         
     | 
| 
      
 106 
     | 
    
         
            +
                tags=[]
         
     | 
| 
      
 107 
     | 
    
         
            +
                @objects.each_with_index do |array, external_index|
         
     | 
| 
      
 108 
     | 
    
         
            +
                  arr=[]
         
     | 
| 
      
 109 
     | 
    
         
            +
                  tags_arr = []
         
     | 
| 
      
 110 
     | 
    
         
            +
                  array.each_with_index do |object, index|
         
     | 
| 
      
 111 
     | 
    
         
            +
                    tag=@tags[external_index][index]
         
     | 
| 
      
 112 
     | 
    
         
            +
                    unless tag == :Hint
         
     | 
| 
      
 113 
     | 
    
         
            +
                      arr << object.my_json
         
     | 
| 
      
 114 
     | 
    
         
            +
                      tags_arr << tag
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end  
         
     | 
| 
      
 117 
     | 
    
         
            +
                  obs << arr unless arr == []
         
     | 
| 
      
 118 
     | 
    
         
            +
                  tags << tags_arr unless arr == []
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
                output[:objects]=obs
         
     | 
| 
      
 121 
     | 
    
         
            +
                output[:tags]=tags
         
     | 
| 
      
 122 
     | 
    
         
            +
                output[:options]=@options
         
     | 
| 
      
 123 
     | 
    
         
            +
                output
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
         
     | 
| 
      
 126 
     | 
    
         
            +
              #returns all the hints — an array of AnnLat objects
         
     | 
| 
      
 127 
     | 
    
         
            +
              def hints
         
     | 
| 
      
 128 
     | 
    
         
            +
                output = []
         
     | 
| 
      
 129 
     | 
    
         
            +
                @objects.each_with_index do |hint, index|
         
     | 
| 
      
 130 
     | 
    
         
            +
                  if @tags[index] == [:Hint]
         
     | 
| 
      
 131 
     | 
    
         
            +
                    output << hint[0]
         
     | 
| 
      
 132 
     | 
    
         
            +
                  end
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
                output
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            class String 
         
     | 
| 
      
 140 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 141 
     | 
    
         
            +
                self
         
     | 
| 
      
 142 
     | 
    
         
            +
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
            end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
            class Latex
         
     | 
| 
      
 146 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 147 
     | 
    
         
            +
                latex
         
     | 
| 
      
 148 
     | 
    
         
            +
              end
         
     | 
| 
      
 149 
     | 
    
         
            +
            end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            class Image
         
     | 
| 
      
 152 
     | 
    
         
            +
              attr_accessor :path    
         
     | 
| 
      
 153 
     | 
    
         
            +
              attr_reader :uuid
         
     | 
| 
      
 154 
     | 
    
         
            +
              attr_reader :options
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
              def initialize(path, options={:dynamic => true})
         
     | 
| 
      
 158 
     | 
    
         
            +
                @options=options
         
     | 
| 
      
 159 
     | 
    
         
            +
                @path=path
         
     | 
| 
      
 160 
     | 
    
         
            +
                @uuid=SecureRandom.uuid
         
     | 
| 
      
 161 
     | 
    
         
            +
              end
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 164 
     | 
    
         
            +
                path
         
     | 
| 
      
 165 
     | 
    
         
            +
              end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            class Hash
         
     | 
| 
      
 170 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 171 
     | 
    
         
            +
                if self[:objects] and self[:types]
         
     | 
| 
      
 172 
     | 
    
         
            +
                  hash={}
         
     | 
| 
      
 173 
     | 
    
         
            +
                  hash[:objects] = self[:objects].map {|row| row.map {|cell| cell.my_json }}
         
     | 
| 
      
 174 
     | 
    
         
            +
                  hash[:types]=self[:types]
         
     | 
| 
      
 175 
     | 
    
         
            +
                  hash
         
     | 
| 
      
 176 
     | 
    
         
            +
                end
         
     | 
| 
      
 177 
     | 
    
         
            +
              end
         
     | 
| 
      
 178 
     | 
    
         
            +
            end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
            #this class represents a table, it's just a two-dimensional array, [[a,x,f],[q]]
         
     | 
| 
      
 181 
     | 
    
         
            +
            class Table
         
     | 
| 
      
 182 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 183 
     | 
    
         
            +
              attr_accessor :objects, :types
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              def my_json
         
     | 
| 
      
 186 
     | 
    
         
            +
                t=Table.new
         
     | 
| 
      
 187 
     | 
    
         
            +
                t.objects = self.objects.map {|row| row.map {|cell| cell.my_json }}
         
     | 
| 
      
 188 
     | 
    
         
            +
                t.types=self.types
         
     | 
| 
      
 189 
     | 
    
         
            +
                t
         
     | 
| 
      
 190 
     | 
    
         
            +
              end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 193 
     | 
    
         
            +
                @objects=[]
         
     | 
| 
      
 194 
     | 
    
         
            +
                @types=[]
         
     | 
| 
      
 195 
     | 
    
         
            +
              end
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
              def each
         
     | 
| 
      
 198 
     | 
    
         
            +
                @objects.each {|row| yield(row)}
         
     | 
| 
      
 199 
     | 
    
         
            +
              end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
              alias_method :each_row, :each
         
     | 
| 
      
 202 
     | 
    
         
            +
            end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
            class Array
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
              def to_table
         
     | 
| 
      
 207 
     | 
    
         
            +
              #  raise "It must be two-dimensional array" unless self.depth==2
         
     | 
| 
      
 208 
     | 
    
         
            +
                table=Table.new
         
     | 
| 
      
 209 
     | 
    
         
            +
                self.each_with_index do |row,i|
         
     | 
| 
      
 210 
     | 
    
         
            +
                  table.objects[i]=row
         
     | 
| 
      
 211 
     | 
    
         
            +
                  temp=[]
         
     | 
| 
      
 212 
     | 
    
         
            +
                  row.each do |item|
         
     | 
| 
      
 213 
     | 
    
         
            +
                    temp << get_type(item)
         
     | 
| 
      
 214 
     | 
    
         
            +
                  end
         
     | 
| 
      
 215 
     | 
    
         
            +
                  table.types[i]=temp
         
     | 
| 
      
 216 
     | 
    
         
            +
                end
         
     | 
| 
      
 217 
     | 
    
         
            +
                table
         
     | 
| 
      
 218 
     | 
    
         
            +
              end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
              #depth of an array
         
     | 
| 
      
 222 
     | 
    
         
            +
              def depth
         
     | 
| 
      
 223 
     | 
    
         
            +
              return 0 if self.class != Array
         
     | 
| 
      
 224 
     | 
    
         
            +
              result = 1
         
     | 
| 
      
 225 
     | 
    
         
            +
              self.each do |sub_a|
         
     | 
| 
      
 226 
     | 
    
         
            +
                if sub_a.class == Array
         
     | 
| 
      
 227 
     | 
    
         
            +
                  dim = sub_a.depth
         
     | 
| 
      
 228 
     | 
    
         
            +
                  result = dim + 1 if dim + 1 > result
         
     | 
| 
      
 229 
     | 
    
         
            +
                end
         
     | 
| 
      
 230 
     | 
    
         
            +
              end
         
     | 
| 
      
 231 
     | 
    
         
            +
              result
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
            end
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Concept
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              def self.name
         
     | 
| 
      
 4 
     | 
    
         
            +
                nil
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def self.version
         
     | 
| 
      
 8 
     | 
    
         
            +
                0
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              def solve
         
     | 
| 
      
 12 
     | 
    
         
            +
                nil
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              def validate(attempt)
         
     | 
| 
      
 16 
     | 
    
         
            +
               attempt.to_f == solve.to_f
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def showQuestion
         
     | 
| 
      
 20 
     | 
    
         
            +
                nil 
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def showAnswer
         
     | 
| 
      
 24 
     | 
    
         
            +
                nil
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def showHow
         
     | 
| 
      
 28 
     | 
    
         
            +
                nil
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def self.whichConcepts
         
     | 
| 
      
 32 
     | 
    
         
            +
                nil
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def variants
         
     | 
| 
      
 36 
     | 
    
         
            +
                nil
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,288 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Latex
         
     | 
| 
      
 2 
     | 
    
         
            +
              def wrap
         
     | 
| 
      
 3 
     | 
    
         
            +
                Wrapped.new(self)
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 7 
     | 
    
         
            +
                ""
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 11 
     | 
    
         
            +
                self
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              alias_method :l, :to_ltx
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def is(y)
         
     | 
| 
      
 17 
     | 
    
         
            +
                LatexConsec.new(self, '=', y)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def ne(y)
         
     | 
| 
      
 21 
     | 
    
         
            +
                LatexConsec.new(self, '\ne ', y)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              def of(*args)
         
     | 
| 
      
 25 
     | 
    
         
            +
                Func.new(self, *args)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def +(y)
         
     | 
| 
      
 29 
     | 
    
         
            +
                Sum.new(self, y)
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def -@
         
     | 
| 
      
 33 
     | 
    
         
            +
                kind_of? Negative ? expr : Negative.new(self)
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def -(y)
         
     | 
| 
      
 37 
     | 
    
         
            +
                Sum.new(self, -y)
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              def *(y)
         
     | 
| 
      
 41 
     | 
    
         
            +
                Product.new(self, y)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def /(y)
         
     | 
| 
      
 45 
     | 
    
         
            +
                Frac.new(self, y)
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              def **(y)
         
     | 
| 
      
 49 
     | 
    
         
            +
                Expon.new(self, y)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              def glue(some_expr)
         
     | 
| 
      
 53 
     | 
    
         
            +
                LatexConsec.new(self, some_expr)
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            class Func < Latex # represents @name(@args)
         
     | 
| 
      
 59 
     | 
    
         
            +
              def initialize(some_name, *some_args)
         
     | 
| 
      
 60 
     | 
    
         
            +
                @name = some_name.to_ltx
         
     | 
| 
      
 61 
     | 
    
         
            +
                @args = some_args.map{|a| a.to_ltx}  
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 65 
     | 
    
         
            +
                return (@name.latex + '()') if @args.length == 0
         
     | 
| 
      
 66 
     | 
    
         
            +
                str = @args[0].latex
         
     | 
| 
      
 67 
     | 
    
         
            +
                @args[1..-1].each {|a| str += (',' + a.latex)}
         
     | 
| 
      
 68 
     | 
    
         
            +
                @name.latex + '(' + str + ')'
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
            end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            class Wrapped < Latex   # should add support for custom wrappings
         
     | 
| 
      
 73 
     | 
    
         
            +
              def initialize(some_expr) 
         
     | 
| 
      
 74 
     | 
    
         
            +
                @wrapee = some_expr.to_ltx 
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              def unwrap
         
     | 
| 
      
 78 
     | 
    
         
            +
                @wrapee
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 82 
     | 
    
         
            +
                '(' + @wrapee.latex + ')'
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
            end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            class Negative < Latex     # represents -@expr
         
     | 
| 
      
 87 
     | 
    
         
            +
              attr_reader :expr
         
     | 
| 
      
 88 
     | 
    
         
            +
              def initialize(some_expr) 
         
     | 
| 
      
 89 
     | 
    
         
            +
                @expr = some_expr.to_ltx 
         
     | 
| 
      
 90 
     | 
    
         
            +
                (@expr = @expr.wrap) if (@expr.kind_of?(Sum))
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 94 
     | 
    
         
            +
                '-' + @expr.latex
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
            end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            class Atom < Latex
         
     | 
| 
      
 99 
     | 
    
         
            +
              def initialize(some_expr)
         
     | 
| 
      
 100 
     | 
    
         
            +
                @expr = some_expr.to_s
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 104 
     | 
    
         
            +
                @expr
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
            end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            class LatexConsec < Latex
         
     | 
| 
      
 109 
     | 
    
         
            +
              def initialize(*some_parts)
         
     | 
| 
      
 110 
     | 
    
         
            +
                @parts = some_parts.map{|i| i.to_ltx}
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 114 
     | 
    
         
            +
                @parts.map{|i| i.latex}.join
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
            end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            class BinOpe < Latex
         
     | 
| 
      
 119 
     | 
    
         
            +
              attr_reader :args
         
     | 
| 
      
 120 
     | 
    
         
            +
              attr_reader :oper
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              def initialize(some_oper, *some_args)
         
     | 
| 
      
 123 
     | 
    
         
            +
                @oper = some_oper.to_ltx
         
     | 
| 
      
 124 
     | 
    
         
            +
                some_args.map!(&:to_ltx)
         
     | 
| 
      
 125 
     | 
    
         
            +
                first = some_args[0]
         
     | 
| 
      
 126 
     | 
    
         
            +
                rest = some_args[1..-1].map {|a| (a.kind_of?(BinOpe) and a.args[0].kind_of?(Negative)) ? a.wrap : a }
         
     | 
| 
      
 127 
     | 
    
         
            +
                @args = [first] + rest
         
     | 
| 
      
 128 
     | 
    
         
            +
              end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 131 
     | 
    
         
            +
                @args.map{|a| a.latex}.join(@oper.latex)
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            class AssocBinOpe < BinOpe
         
     | 
| 
      
 136 
     | 
    
         
            +
              def initialize(some_oper, *some_args) 
         
     | 
| 
      
 137 
     | 
    
         
            +
                super(some_oper, *(some_args.map{|a| (a.kind_of?(AssocBinOpe) and (a.oper == @oper))? a.args : a}.flatten))
         
     | 
| 
      
 138 
     | 
    
         
            +
              end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              def latex() 
         
     | 
| 
      
 141 
     | 
    
         
            +
                @args.map{|i| i.latex}.join(@oper.latex)
         
     | 
| 
      
 142 
     | 
    
         
            +
             end
         
     | 
| 
      
 143 
     | 
    
         
            +
            end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
            class Product < AssocBinOpe
         
     | 
| 
      
 146 
     | 
    
         
            +
              def initialize(*some_factors)
         
     | 
| 
      
 147 
     | 
    
         
            +
                super(Times, *some_factors)
         
     | 
| 
      
 148 
     | 
    
         
            +
                @args.map!{|a| (a.kind_of?(Negative) or a.kind_of?(Sum))? a.wrap : a}
         
     | 
| 
      
 149 
     | 
    
         
            +
              end  
         
     | 
| 
      
 150 
     | 
    
         
            +
            end
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
            class Sum < Latex
         
     | 
| 
      
 153 
     | 
    
         
            +
              def initialize(*some_summands)
         
     | 
| 
      
 154 
     | 
    
         
            +
                @summands = some_summands.map(&:to_ltx)
         
     | 
| 
      
 155 
     | 
    
         
            +
              end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
              def latex 
         
     | 
| 
      
 158 
     | 
    
         
            +
                str = @summands[0].latex
         
     | 
| 
      
 159 
     | 
    
         
            +
                @summands[1..-1].each{|a| a.kind_of?(Negative) ? str += (a.latex) : str += ('+' + a.latex)}
         
     | 
| 
      
 160 
     | 
    
         
            +
                str
         
     | 
| 
      
 161 
     | 
    
         
            +
              end
         
     | 
| 
      
 162 
     | 
    
         
            +
            end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
            class Frac < Latex
         
     | 
| 
      
 165 
     | 
    
         
            +
              def initialize(some_numer, some_denom)
         
     | 
| 
      
 166 
     | 
    
         
            +
                @numer = some_numer.to_ltx
         
     | 
| 
      
 167 
     | 
    
         
            +
                @denom = some_denom.to_ltx
         
     | 
| 
      
 168 
     | 
    
         
            +
              end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 171 
     | 
    
         
            +
                '\frac{' + @numer.latex + '}{' + @denom.latex + '}'
         
     | 
| 
      
 172 
     | 
    
         
            +
              end
         
     | 
| 
      
 173 
     | 
    
         
            +
            end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            class Expon < Latex
         
     | 
| 
      
 176 
     | 
    
         
            +
              def initialize(some_base, some_exp)
         
     | 
| 
      
 177 
     | 
    
         
            +
                @base = some_base.to_ltx
         
     | 
| 
      
 178 
     | 
    
         
            +
                @exp = some_exp.to_ltx
         
     | 
| 
      
 179 
     | 
    
         
            +
              end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 182 
     | 
    
         
            +
                the_base = @base.wrap if (@base.kind_of?(Expon) or @base.kind_of?(Negative) or @base.kind_of?(BinOpe))
         
     | 
| 
      
 183 
     | 
    
         
            +
                the_base.latex + '^{' + @exp.latex +  '}'
         
     | 
| 
      
 184 
     | 
    
         
            +
              end
         
     | 
| 
      
 185 
     | 
    
         
            +
            end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            class Fixnum
         
     | 
| 
      
 188 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 189 
     | 
    
         
            +
                (self >= 0) ? Atom.new(self) : -(Atom.new(-self))
         
     | 
| 
      
 190 
     | 
    
         
            +
              end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
              alias_method :l, :to_ltx
         
     | 
| 
      
 193 
     | 
    
         
            +
            end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
            class Float
         
     | 
| 
      
 196 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 197 
     | 
    
         
            +
                (self >= 0) ? Atom.new(self) : -(Atom.new(-self))
         
     | 
| 
      
 198 
     | 
    
         
            +
              end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              alias_method :l, :to_ltx
         
     | 
| 
      
 201 
     | 
    
         
            +
            end
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            class String
         
     | 
| 
      
 204 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 205 
     | 
    
         
            +
                Atom.new(self)
         
     | 
| 
      
 206 
     | 
    
         
            +
              end
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
              alias_method :l, :to_ltx
         
     | 
| 
      
 209 
     | 
    
         
            +
            end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
            class LatexList < Atom
         
     | 
| 
      
 212 
     | 
    
         
            +
              def initialize(arr)
         
     | 
| 
      
 213 
     | 
    
         
            +
                @list = arr
         
     | 
| 
      
 214 
     | 
    
         
            +
              end
         
     | 
| 
      
 215 
     | 
    
         
            +
              
         
     | 
| 
      
 216 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 217 
     | 
    
         
            +
                "(" + @list.join(", ") + ")"
         
     | 
| 
      
 218 
     | 
    
         
            +
              end
         
     | 
| 
      
 219 
     | 
    
         
            +
            end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
            class Array
         
     | 
| 
      
 222 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 223 
     | 
    
         
            +
                a = map{ |obj| obj.to_ltx.latex }
         
     | 
| 
      
 224 
     | 
    
         
            +
                LatexList.new(a)
         
     | 
| 
      
 225 
     | 
    
         
            +
              end
         
     | 
| 
      
 226 
     | 
    
         
            +
            end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
            class LatexSet < Atom
         
     | 
| 
      
 229 
     | 
    
         
            +
              def initialize(s)
         
     | 
| 
      
 230 
     | 
    
         
            +
                @set = s.to_a
         
     | 
| 
      
 231 
     | 
    
         
            +
              end
         
     | 
| 
      
 232 
     | 
    
         
            +
              
         
     | 
| 
      
 233 
     | 
    
         
            +
              def latex
         
     | 
| 
      
 234 
     | 
    
         
            +
                "{" + @set.join(", ") + "}"
         
     | 
| 
      
 235 
     | 
    
         
            +
              end
         
     | 
| 
      
 236 
     | 
    
         
            +
            end
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
            class Set
         
     | 
| 
      
 239 
     | 
    
         
            +
              def to_ltx
         
     | 
| 
      
 240 
     | 
    
         
            +
                s = map{ |obj| obj.to_ltx.latex }
         
     | 
| 
      
 241 
     | 
    
         
            +
                LatexSet.new(s)
         
     | 
| 
      
 242 
     | 
    
         
            +
              end
         
     | 
| 
      
 243 
     | 
    
         
            +
            end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
            Plus = Atom.new('+')
         
     | 
| 
      
 247 
     | 
    
         
            +
            Times = Atom.new('\cdot ')
         
     | 
| 
      
 248 
     | 
    
         
            +
            Minus = Atom.new('-')
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
            #      Greek alphabet
         
     | 
| 
      
 251 
     | 
    
         
            +
            def alpha() Atom.new('\alpha ') end
         
     | 
| 
      
 252 
     | 
    
         
            +
            def beta() Atom.new('\beta ') end
         
     | 
| 
      
 253 
     | 
    
         
            +
            def gamma() Atom.new('\gamma ') end
         
     | 
| 
      
 254 
     | 
    
         
            +
            def delta() Atom.new('\delta ') end
         
     | 
| 
      
 255 
     | 
    
         
            +
            def epsilon() Atom.new('\epsilon ') end
         
     | 
| 
      
 256 
     | 
    
         
            +
            def varepsilon() Atom.new('\varepsilon ') end
         
     | 
| 
      
 257 
     | 
    
         
            +
            def zeta() Atom.new('\zeta ') end
         
     | 
| 
      
 258 
     | 
    
         
            +
            def eta() Atom.new('\eta ') end
         
     | 
| 
      
 259 
     | 
    
         
            +
            def theta() Atom.new('\theta ') end
         
     | 
| 
      
 260 
     | 
    
         
            +
            def vartheta() Atom.new('\vartheta ') end
         
     | 
| 
      
 261 
     | 
    
         
            +
            def kappa() Atom.new('\kappa ') end
         
     | 
| 
      
 262 
     | 
    
         
            +
            def mu() Atom.new('\mu ') end
         
     | 
| 
      
 263 
     | 
    
         
            +
            def nu() Atom.new('\nu ') end
         
     | 
| 
      
 264 
     | 
    
         
            +
            def xi() Atom.new('\xi ') end
         
     | 
| 
      
 265 
     | 
    
         
            +
            def pi() Atom.new('\pi ') end
         
     | 
| 
      
 266 
     | 
    
         
            +
            def varpi() Atom.new('\varpi ') end
         
     | 
| 
      
 267 
     | 
    
         
            +
            def rho() Atom.new('\rho ') end
         
     | 
| 
      
 268 
     | 
    
         
            +
            def varrho() Atom.new('\varrho ') end
         
     | 
| 
      
 269 
     | 
    
         
            +
            def sigma() Atom.new('\sigma ') end
         
     | 
| 
      
 270 
     | 
    
         
            +
            def varsigma() Atom.new('\varsigma ') end
         
     | 
| 
      
 271 
     | 
    
         
            +
            def tau() Atom.new('\tau ') end
         
     | 
| 
      
 272 
     | 
    
         
            +
            def upsilon() Atom.new('\upsilon ') end
         
     | 
| 
      
 273 
     | 
    
         
            +
            def phi() Atom.new('\phi ') end
         
     | 
| 
      
 274 
     | 
    
         
            +
            def varphi() Atom.new('\varphi ') end
         
     | 
| 
      
 275 
     | 
    
         
            +
            def chi() Atom.new('\chi ') end
         
     | 
| 
      
 276 
     | 
    
         
            +
            def psi() Atom.new('\psi ') end
         
     | 
| 
      
 277 
     | 
    
         
            +
            def omega() Atom.new('\omega ') end
         
     | 
| 
      
 278 
     | 
    
         
            +
            def cGamma() Atom.new('\Gamma ') end
         
     | 
| 
      
 279 
     | 
    
         
            +
            def cDelta() Atom.new('\Delta ') end
         
     | 
| 
      
 280 
     | 
    
         
            +
            def cTheta() Atom.new('\Theta ') end
         
     | 
| 
      
 281 
     | 
    
         
            +
            def cLambda() Atom.new('\Lmabda ') end
         
     | 
| 
      
 282 
     | 
    
         
            +
            def cXi() Atom.new('\Xi ') end
         
     | 
| 
      
 283 
     | 
    
         
            +
            def cPi() Atom.new('\Pi ') end
         
     | 
| 
      
 284 
     | 
    
         
            +
            def cSigma() Atom.new('\Sigma ') end
         
     | 
| 
      
 285 
     | 
    
         
            +
            def cUpsilon() Atom.new('\Upsilon ') end
         
     | 
| 
      
 286 
     | 
    
         
            +
            def cPhi() Atom.new('\Phi ') end
         
     | 
| 
      
 287 
     | 
    
         
            +
            def cPsi() Atom.new('\Psi ') end
         
     | 
| 
      
 288 
     | 
    
         
            +
            def cOmega() Atom.new('\Omega ') end
         
     | 
| 
         @@ -0,0 +1,72 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            def final?
         
     | 
| 
      
 2 
     | 
    
         
            +
              instance_methods(false).include? :showHow
         
     | 
| 
      
 3 
     | 
    
         
            +
            end
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            public :final?
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            class Fixnum
         
     | 
| 
      
 8 
     | 
    
         
            +
              def prettify
         
     | 
| 
      
 9 
     | 
    
         
            +
                self
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            class Float
         
     | 
| 
      
 14 
     | 
    
         
            +
              def prettify
         
     | 
| 
      
 15 
     | 
    
         
            +
                to_i == self ? to_i : self
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            class Rational
         
     | 
| 
      
 20 
     | 
    
         
            +
              def prettify
         
     | 
| 
      
 21 
     | 
    
         
            +
                if self.denominator==1
         
     | 
| 
      
 22 
     | 
    
         
            +
                  self.numerator 
         
     | 
| 
      
 23 
     | 
    
         
            +
                else
         
     | 
| 
      
 24 
     | 
    
         
            +
                  self
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            class Concept
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              attr_accessor :images
         
     | 
| 
      
 32 
     | 
    
         
            +
              attr_accessor :uuid
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def move_image(img)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  uuid=img.uuid
         
     | 
| 
      
 37 
     | 
    
         
            +
                  path=img.path
         
     | 
| 
      
 38 
     | 
    
         
            +
                  if !img.options[:dynamic]
         
     | 
| 
      
 39 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 40 
     | 
    
         
            +
                      FileUtils.mv("engine/concepts/#{path}", "public/images/#{self.class}/static/#{path}")
         
     | 
| 
      
 41 
     | 
    
         
            +
                    rescue Errno::ENOENT
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
                    img.path = "#{self.class}/static/#{path}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                  else
         
     | 
| 
      
 45 
     | 
    
         
            +
                    img.path= "#{self.class}/#{uuid}"
         
     | 
| 
      
 46 
     | 
    
         
            +
                    FileUtils.mv("#{path}", "public/images/#{self.class}/#{uuid}")
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end    
         
     | 
| 
      
 48 
     | 
    
         
            +
                  img
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def move_images
         
     | 
| 
      
 52 
     | 
    
         
            +
                concept=self
         
     | 
| 
      
 53 
     | 
    
         
            +
                @images=[] if @images.nil?
         
     | 
| 
      
 54 
     | 
    
         
            +
                begin
         
     | 
| 
      
 55 
     | 
    
         
            +
                  Dir.mkdir("public/images/#{self.class}")
         
     | 
| 
      
 56 
     | 
    
         
            +
                rescue Errno::EEXIST
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
                begin
         
     | 
| 
      
 59 
     | 
    
         
            +
                  Dir.mkdir("public/images/#{self.class}/static")
         
     | 
| 
      
 60 
     | 
    
         
            +
                rescue Errno::EEXIST
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
                @images.map {|x| move_image(x)}
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              def addImage(img)
         
     | 
| 
      
 66 
     | 
    
         
            +
                @images=[] if @images.nil?
         
     | 
| 
      
 67 
     | 
    
         
            +
                raise "You tried to add not an image" if img.class!=Image
         
     | 
| 
      
 68 
     | 
    
         
            +
                @images << img
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,70 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: annlat
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Alexander Shevtsov
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-10-16 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: ''
         
     | 
| 
      
 28 
     | 
    
         
            +
            email:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - randomlogin76@gmail.com
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 35 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 36 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 37 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 38 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 39 
     | 
    
         
            +
            - annlat.gemspec
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/annlat.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/annlat/AnnLat.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/annlat/Concept.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/annlat/LaRuby.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/annlat/Sundries.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/annlat/version.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            homepage: ''
         
     | 
| 
      
 47 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 48 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 49 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 50 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 51 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 52 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 54 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 55 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 56 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 57 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 58 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 59 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 60 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 61 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 62 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 63 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 64 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 65 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 66 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
      
 67 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 68 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 69 
     | 
    
         
            +
            summary: Learnleague gem for containg used libraries
         
     | 
| 
      
 70 
     | 
    
         
            +
            test_files: []
         
     |