Class: BBS2ch::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/bbs2ch/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, email, time, id, be, body, title) ⇒ Post

Returns a new instance of Post.



3
4
5
6
7
8
9
10
11
# File 'lib/bbs2ch/post.rb', line 3

def initialize(name, email, time, id, be, body, title)
  @name  = name
  @email = email
  @time  = time
  @id    = id
  @be    = be
  @body  = body
  @title = title
end

Instance Attribute Details

#beObject

Returns the value of attribute be.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def be
  @be
end

#bodyObject

Returns the value of attribute body.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def body
  @body
end

#emailObject

Returns the value of attribute email.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def email
  @email
end

#idObject

Returns the value of attribute id.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def id
  @id
end

#nameObject

Returns the value of attribute name.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def name
  @name
end

#timeObject

Returns the value of attribute time.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def time
  @time
end

#titleObject

Returns the value of attribute title.



33
34
35
# File 'lib/bbs2ch/post.rb', line 33

def title
  @title
end

Instance Method Details

#fc2Object



25
26
27
# File 'lib/bbs2ch/post.rb', line 25

def fc2
  fix_ttp @body.scan(%r{ttp://video\.fc2\.com/a/content/[0-9a-zA-Z]+})
end

#fix_ttp(urls) ⇒ Object



29
30
31
# File 'lib/bbs2ch/post.rb', line 29

def fix_ttp(urls)
  urls.map { |url| url.gsub(/^ttp/, 'http') }
end

#imagesObject



13
14
15
# File 'lib/bbs2ch/post.rb', line 13

def images
  fix_ttp @body.scan(%r{ttps?:.*\.(?:jpg|png|gif)})
end

#videosObject



17
18
19
# File 'lib/bbs2ch/post.rb', line 17

def videos
  xvideos + fc2
end

#xvideosObject



21
22
23
# File 'lib/bbs2ch/post.rb', line 21

def xvideos
  fix_ttp @body.scan(%r{ttp://(?:www|jp)\.xvideos\.com/video[0-9]+})
end