Class: PintrestApi::Pin

Inherits:
Core
  • Object
show all
Extended by:
Authentication
Defined in:
lib/pintrest_api/pin.rb

Overview

Pintrest Pin model

Constant Summary collapse

PINTREST_URL =
'http://www.pinterest.com'
PIN_BASE_CSS =
'.Grid .Pin'
PIN_IMAGE_CSS =
'.pinHolder .pinImg'
PIN_TITLE_CSS =
'.richPinGridTitle'
PIN_CREDIT_CSS =
'.creditItem a'
PIN_URL_CSS =
'.pinHolder .pinImageWrapper'
PIN_DESCRIPT_CSS =
'.pinDescription'

Constants included from Authentication

Authentication::EMAIL_INPUT_CSS, Authentication::LOGIN_PAGE_BUTTON_CSS, Authentication::PASSWORD_INPUT_CSS, Authentication::PINTREST_LOGIN_URL

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from Authentication

#is_logged_in

Attributes inherited from Core

#session

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

try_or_check_login

Methods inherited from Core

click, get_with_ajax_scroll, html, new_session, scroll_page, session_visit, stream_with_ajax_scroll, visit, visit_page

Constructor Details

#initialize(image_url, title, credits_url, url, description) ⇒ Pin

Returns a new instance of Pin.



16
17
18
19
20
21
22
# File 'lib/pintrest_api/pin.rb', line 16

def initialize(image_url, title, credits_url, url, description)
  @image_url   = image_url
  @title       = title
  @credits_url = credits_url
  @url         = url
  @description = description
end

Class Attribute Details

.is_logged_inObject

Returns the value of attribute is_logged_in.



26
27
28
# File 'lib/pintrest_api/pin.rb', line 26

def is_logged_in
  @is_logged_in
end

Instance Attribute Details

#credits_urlObject (readonly)

Returns the value of attribute credits_url.



6
7
8
# File 'lib/pintrest_api/pin.rb', line 6

def credits_url
  @credits_url
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/pintrest_api/pin.rb', line 6

def description
  @description
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



6
7
8
# File 'lib/pintrest_api/pin.rb', line 6

def image_url
  @image_url
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/pintrest_api/pin.rb', line 6

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/pintrest_api/pin.rb', line 6

def url
  @url
end

Class Method Details

.get_for_board(board, authentication = nil) ⇒ Object

Gets all pins from a board url

Attributes

  • board - Pintrest board

  • authentication -

Examples

PintrestApi::Pin.get_for_board(board, ‘[email protected]’, password: ‘asdf’)



54
55
56
57
58
59
# File 'lib/pintrest_api/pin.rb', line 54

def get_for_board(board, authentication = nil)
   authentication

  session_visit http_url(board.url)
  parse_pins get_with_ajax_scroll(PIN_BASE_CSS)
end

.get_for_board_stream(board, authentication = nil) ⇒ Object

Gets all pins from a board url

Attributes

  • board - Pintrest board

  • authentication -

  • &block - a stream of every 25ish pins

Examples

PintrestApi::Pin.get_for_board_stream(board, ‘[email protected]’, password: ‘asdf’) do |pins| end



72
73
74
75
76
77
78
79
# File 'lib/pintrest_api/pin.rb', line 72

def get_for_board_stream(board, authentication = nil)
   authentication

  session_visit http_url(board.url)
  stream_with_ajax_scroll(PIN_BASE_CSS) do |pins|
    yield parse_pins pins
  end
end

.get_for_board_url(board_url, authentication) ⇒ Object

Gets all pins from a board url

Attributes

  • board_url - Pintrest board url

  • authentication -

Examples

PintrestApi::Pin.get_for_board_url(‘pintrest.com/mikaak/my-pins’, ‘[email protected]’, password: ‘asdf’)



37
38
39
40
41
42
# File 'lib/pintrest_api/pin.rb', line 37

def get_for_board_url(board_url, authentication)
   authentication

  session_visit http_url(board_url)
  parse_pins get_with_ajax_scroll(PIN_BASE_CSS)
end