Class: Niconico::Fabric
- Inherits:
-
Object
- Object
- Niconico::Fabric
- Defined in:
- lib/nv/niconico/fabric.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Instance Method Summary collapse
-
#initialize(agent = nil) ⇒ Fabric
constructor
A new instance of Fabric.
- #sign_in(email, password) ⇒ Object
- #signed_in? ⇒ Boolean
Constructor Details
#initialize(agent = nil) ⇒ Fabric
Returns a new instance of Fabric.
5 6 7 8 |
# File 'lib/nv/niconico/fabric.rb', line 5 def initialize(agent=nil) @agent = agent || Mechanize.new @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
3 4 5 |
# File 'lib/nv/niconico/fabric.rb', line 3 def agent @agent end |
Instance Method Details
#sign_in(email, password) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/nv/niconico/fabric.rb', line 10 def sign_in(email, password) @agent.post( "https://secure.nicovideo.jp/secure/login?site=niconico", "mail" => email, "password" => password ) return self end |
#signed_in? ⇒ Boolean
19 20 21 |
# File 'lib/nv/niconico/fabric.rb', line 19 def signed_in? @agent..any? {|c| c.name == 'user_session'} end |