Class: Stratagem::Crawler::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/stratagem/crawler/form.rb

Direct Known Subclasses

Button, Select, Toggle

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#id ⇒ Object

Returns the value of attribute id.



48
49
50
# File 'lib/stratagem/crawler/form.rb', line 48

def id
  @id
end

#name ⇒ Object

Returns the value of attribute name.



48
49
50
# File 'lib/stratagem/crawler/form.rb', line 48

def name
  @name
end

#type ⇒ Object

Returns the value of attribute type.



49
50
51
# File 'lib/stratagem/crawler/form.rb', line 49

def type
  @type
end

#value ⇒ Object

Returns the value of attribute value.



49
50
51
# File 'lib/stratagem/crawler/form.rb', line 49

def value
  @value
end

Instance Method Details

#guess_alternate_attribute ⇒ Object



71
72
73
74
75
76
77
# File 'lib/stratagem/crawler/form.rb', line 71

def guess_alternate_attribute
  if (name =~ /(.*)\[(.*)\]/)
    $2.to_sym
  else
    name.to_sym
  end
end

#guess_attribute ⇒ Object



63
64
65
66
67
68
69
# File 'lib/stratagem/crawler/form.rb', line 63

def guess_attribute
  if (name =~ /.*\[(.*)\]/)
    $1.to_sym
  else
    name.to_sym
  end
end

#guess_model ⇒ Object



79
80
81
82
# File 'lib/stratagem/crawler/form.rb', line 79

def guess_model
  return $1.camelize if (name =~ /(.*)?\[/)
  return nil
end

#hidden? ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/stratagem/crawler/form.rb', line 84

def hidden?
  self.type == 'hidden'
end