class PintrestApi::Board
Pintrest Boards this is used to fetch boards and related pins
Constants
- BOARD_ITEM_CSS
- BOARD_LINK_CSS
- BOARD_PIN_COUNT_CSS
- BOARD_TITLE_CSS
- PINTREST_URL
Attributes
pin_count[R]
title[R]
url[R]
Public Class Methods
all(user_name, authentication)
click to toggle source
Gets all boards from a user
Attributes¶ ↑
-
user_name
- Pintrest username
Examples¶ ↑
PintrestApi::Board.all
(‘mikakalathil’)
# File lib/pintrest_api/board.rb, line 44 def all(user_name, authentication) try_or_check_login authentication session_visit user_name @session.save_and_open_page parse_boards get_with_ajax_scroll(BOARD_ITEM_CSS) end
new(title, board_url, pin_count)
click to toggle source
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)
# 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
pins(user_name, board_name, authentication)
click to toggle source
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!!!’, {email: ‘asdf@gmail.com’, password: ‘asdf’})
# File lib/pintrest_api/board.rb, line 63 def pins(user_name, board_name, authentication) try_or_check_login authentication board_slug = board_name.downcase.gsub(/[_\s]/, '-') Pin.get_for_board_url("#{user_name}/#{board_slug}", authentication) end
Private Class Methods
parse_boards(nokogiri_items)
click to toggle source
# File lib/pintrest_api/board.rb, line 72 def parse_boards(nokogiri_items) items = [] nokogiri_items.each do |item| board_title = item.css(BOARD_TITLE_CSS).inner_text board_link = PINTREST_URL.chomp('/') + item.css(BOARD_LINK_CSS).attribute('href').value pin_count = item.css(BOARD_PIN_COUNT_CSS).inner_text.strip items << Board.new(board_title, board_link, pin_count) end items end
Public Instance Methods
pins()
click to toggle source
# File lib/pintrest_api/board.rb, line 29 def pins Pin.get_for_board(self) end