Class: FourchanUrler::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/fourchan-urler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Request

Returns a new instance of Request.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fourchan-urler.rb', line 9

def initialize(url)
  uri = URI(url)

  if uri.host == "boards.4chan.org" && uri.path.path_check

    @thread_id = url[/(\d{3,})/].to_i
    @board = url[/\/[a-z]+\//][/[a-z]+/]
  else
    raise ArgumentError, 'URL is incorrect. Please use 4chan thread URL.'
  end
end

Instance Attribute Details

#boardObject

Returns the value of attribute board.



7
8
9
# File 'lib/fourchan-urler.rb', line 7

def board
  @board
end

#thread_idObject

Returns the value of attribute thread_id.



7
8
9
# File 'lib/fourchan-urler.rb', line 7

def thread_id
  @thread_id
end