Sha256: e7954d6339e1f8bf31df8780987d997f6116081756a7038313f6ab63f5f5c903

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

module Ugigi
  class Scheme
    attr_accessor :element

    def initialize(element)
      @element = element
    end
    
    def method_missing(action, *args)
      return @element[action.to_s] rescue nil
    end
    
    def params() @element.keys.map{|k|k.to_sym} ; end
    alias_method :available_methods, :params
  end
  
  class Index < Scheme    
    def to_sosowa_index
      log = @element["link"].scan(/log=(\d+)/)[0][0].to_i
      key = @element["link"].scan(/key=(\d+)/)[0][0].to_i
      index = {
        "log" => log,
        "key" => key,
        "title" => @element["title"],
        "author" => @element["author"],
        "created_at" => @element["posted_at"],
        "updated_at" => @element["updated_at"],
        "review_count" => nil,
        "comment_count" => @element["comment"],
        "point" => @element["point"],
        "tags" => @element["tags"],
        "rate" => @element["eval"],
        "size" => @element["size"],
        "url" => @element["link"]
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ugigi-0.4.2 lib/ugigi/scheme.rb
ugigi-0.4.1 lib/ugigi/scheme.rb
ugigi-0.4 lib/ugigi/scheme.rb