class AnnLat

Attributes

objects[RW]
options[RW]
tags[RW]

Public Class Methods

new() click to toggle source
# File lib/annlat/AnnLat.rb, line 45
def initialize
  @objects = []
  @tags = []
  @options = {}
end

Public Instance Methods

+(x) click to toggle source
# File lib/annlat/AnnLat.rb, line 61
def +(x)
  out=AnnLat.new
  out.objects=self.objects+x.objects
  out.tags=self.tags+x.tags
  out
end
add(*stuff) click to toggle source
# File lib/annlat/AnnLat.rb, line 68
def add(*stuff) # adds stuff to the @objects array, in sequential order.
  arr1=[]
  arr2=[]
  stuff.flatten.each do |object|
    case get_type(object)
    when :Table
      hash = {}
      hash[:objects]=object.objects
      hash[:types]=object.types
      arr1 << hash
      arr2 << :Table
    #when :Image
    #  str = object.path
    #  arr1 << str
    #  arr2 << get_type(object)
    else
      arr1 << object
      arr2 << get_type(object)
    end

  end
  @objects << arr1
  @tags << arr2
  self
end
addHint(*stuff) click to toggle source

hint is new AnnLat object that is passed with tag :Hint

# File lib/annlat/AnnLat.rb, line 95
def addHint(*stuff)
  x=AnnLat.new
  x.add(*stuff)
  @objects << [x]
  @tags << [:Hint]
  self
end
each() { |x| ... } click to toggle source
# File lib/annlat/AnnLat.rb, line 57
def each
  @objects.each {|x| yield(x)}
end
each_with_symbols() { |objects[0],tags[0]| ... } click to toggle source
# File lib/annlat/AnnLat.rb, line 51
def each_with_symbols
  @objects.each_with_index do |x,i|
    yield(@objects[i][0],@tags[i][0])
  end
end
hints() click to toggle source

returns all the hints — an array of AnnLat objects

# File lib/annlat/AnnLat.rb, line 127
def hints
  output = []
  @objects.each_with_index do |hint, index|
    if @tags[index] == [:Hint]
      output << hint[0]
    end
  end
  output
end
my_json() click to toggle source
# File lib/annlat/AnnLat.rb, line 103
def my_json
  output={} 
  obs=[]
  tags=[]
  @objects.each_with_index do |array, external_index|
    arr=[]
    tags_arr = []
    array.each_with_index do |object, index|
      tag=@tags[external_index][index]
      unless tag == :Hint
        arr << object.my_json
        tags_arr << tag
      end
    end  
    obs << arr unless arr == []
    tags << tags_arr unless arr == []
  end
  output[:objects]=obs
  output[:tags]=tags
  output[:options]=@options
  output
end