Class: Simple2ch::Board

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, url, fetch_title: nil) ⇒ Board

Returns a new instance of Board.

Parameters:

  • title (String)

    板の名前

  • url (String)

    板のURL

  • [Boolean] (Hash)

    a customizable set of options



16
17
18
19
20
21
22
23
24
25
# File 'lib/simple2ch/board.rb', line 16

def initialize(title, url, fetch_title:nil)
  @server_name = @board_name = nil
  @url = validate_url url
  @title = if fetch_title
             (b=Simple2ch.boards(url).find{|bb| bb.url.to_s == @url.to_s}) &&  b.class!=Array ? b.title : nil
           else
             title
           end
  @thres = []
end

Instance Attribute Details

#board_nameString (readonly)

Returns 板の名前(コンピュータ名).

Returns:

  • (String)

    板の名前(コンピュータ名)



10
11
12
# File 'lib/simple2ch/board.rb', line 10

def board_name
  @board_name
end

#server_nameString (readonly)

Returns サーバ名.

Returns:

  • (String)

    サーバ名



8
9
10
# File 'lib/simple2ch/board.rb', line 8

def server_name
  @server_name
end

#titleString (readonly)

Returns 板のタイトル.

Returns:

  • (String)

    板のタイトル



6
7
8
# File 'lib/simple2ch/board.rb', line 6

def title
  @title
end

#urlURI (readonly)

Returns 板のURL.

Returns:

  • (URI)

    板のURL



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

def url
  @url
end

Instance Method Details

#open2ch?Boolean

おーぷん2chか否かを返す

Returns:

  • (Boolean)

    おーぷん2chか否か



39
40
41
# File 'lib/simple2ch/board.rb', line 39

def open2ch?
  @f_open2ch && true
end

#thresArray<Thre>

板に属する全てのスレッドを返す

Returns:

  • (Array<Thre>)

    板に属する全てのスレッド



29
30
31
32
33
34
35
# File 'lib/simple2ch/board.rb', line 29

def thres
  if @thres.size > 0
    @thres
  else
    fetch_all_thres
  end
end

#type_of_2chSymbol

2chタイプ名の取得

Returns:

  • (Symbol)

    2chタイプ名(:net, :sc, :open)



45
46
47
# File 'lib/simple2ch/board.rb', line 45

def type_of_2ch
  Simple2ch.type_of_2ch(@url.to_s)
end