Sha256: 9f624e9b2895d8a58492ba26908e3aae13a1816b8b2c443a6b5d37d6de2c0d37

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

module WWMD
  class Inputs
    attr_accessor :elems

    @cobj  = '' # wwmd object
    @elems = '' # array of elems parse out by self.new()

    def initialize(*args)
      @cobj = args.shift
    end

    def show
      puts @elems
    end

    # call me from Page.set_data
    def set
      @elems = [@cobj.search("//input").map,@cobj.search("//select").map].flatten
    end

    def get(attr=nil)
      @elems.map { |x| x[attr] }.reject { |y| y.nil? }
    end

    #
    # return: FormArray containing all page inputs
    def form
      ret = {}
      @elems.map do |x|
        name  = x['name']
        id    = x['id']
        next if (name.nil? && id.nil?)
        value = x['value']
        type  = x['type']
        ret[name] = value
        ret[id] = value if ((id || name) != name)
      end
      return FormArray.new(ret)
    end

    #
    # return: FormArray containing get params
    def params
      return FormArray.new(@cobj.cur.clop.to_form)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
miketracy-wwmd-0.2.11 lib/wwmd/page/inputs.rb
miketracy-wwmd-0.2.12 lib/wwmd/page/inputs.rb
miketracy-wwmd-0.2.14 lib/wwmd/page/inputs.rb
miketracy-wwmd-0.2.15 lib/wwmd/page/inputs.rb
miketracy-wwmd-0.2.16 lib/wwmd/page/inputs.rb