Class: PintrestApi::Board

Inherits:
Core
  • Object
show all
Defined in:
lib/pintrest_api/board.rb

Overview

Pintrest Boards this is used to fetch boards and related pins

Constant Summary collapse

PINTREST_URL =
'http://www.pintrest.com/'
BOARD_PIN_COUNT_CSS =
'.PinCount'
'.boardLinkWrapper'
BOARD_TITLE_CSS =
'h3.boardName .title'
BOARD_ITEM_CSS =
'.GridItems > .item'

Instance Attribute Summary collapse

Attributes inherited from Core

#session

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core

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

Constructor Details

#initialize(title, board_url, pin_count) ⇒ Board

Get a instance of a board

Attributes

  • title - Pintrest board title

  • board_url - Pintrest board url

  • pin_count - Pintrest boards pin count

Examples

PintrestApi::Board.new(‘Yummy Pins’, ‘pintrest.com/mikaak/yummy-pins’, 38)



23
24
25
26
27
# File 'lib/pintrest_api/board.rb', line 23

def initialize(title, board_url, pin_count)
  @title = title
  @url = board_url
  @pin_count = pin_count
end

Instance Attribute Details

#pin_countObject (readonly)

Returns the value of attribute pin_count.



4
5
6
# File 'lib/pintrest_api/board.rb', line 4

def pin_count
  @pin_count
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/pintrest_api/board.rb', line 4

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/pintrest_api/board.rb', line 4

def url
  @url
end

Class Method Details

.all(user_name) ⇒ Object

Gets all boards from a user

Attributes

  • user_name - Pintrest username

Examples

PintrestApi::Board.all(‘mikakalathil’)



43
44
45
46
# File 'lib/pintrest_api/board.rb', line 43

def all(user_name)
  visit_page user_name
  parse_boards get_with_ajax_scroll(BOARD_ITEM_CSS)
end

.pins(user_name, board_name, authentication) ⇒ Object

Gets all pins from a specific board

Attributes

  • user_name - Pintrest username

  • board_name - Pintrest board_name

Examples

PintrestApi::Board.pins(‘mikakalathil’, ‘My Board Name!!!’)



58
59
60
61
# File 'lib/pintrest_api/board.rb', line 58

def pins(user_name, board_name, authentication)
  board_slug = board_name.downcase.gsub(/[_\s]/, '-')
  Pin.get_for_board_url("#{PINTREST_URL}#{user_name}/#{board_slug}", authentication)
end

Instance Method Details

#pinsObject



29
30
31
# File 'lib/pintrest_api/board.rb', line 29

def pins
  Pin.get_for_board(self)
end