Class: Nokaya::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/nokaya/basic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ Basic

Returns a new instance of Basic.



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

def initialize args, options
  @options = options
  @workers = Workers.new(options)
  @args = @workers.check_args(args)
  @file_name = []
  @image_url = []
  @path = @workers.path
  @type = :basic
  @name = options['name'] if options['name']
  @platform = RbConfig::CONFIG['host_os']
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def args
  @args
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def file_name
  @file_name
end

#image_urlObject

Returns the value of attribute image_url.



7
8
9
# File 'lib/nokaya/basic.rb', line 7

def image_url
  @image_url
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/nokaya/basic.rb', line 6

def type
  @type
end

Instance Method Details

#get_basic(page) ⇒ Object



21
22
23
# File 'lib/nokaya/basic.rb', line 21

def get_basic page
  page.xpath("//meta[@property='og:image']/@content").first.value
end

#parse(url) ⇒ Object



25
26
27
# File 'lib/nokaya/basic.rb', line 25

def parse url
  Nokogiri::HTML(open url)
end

#saveObject



29
30
31
# File 'lib/nokaya/basic.rb', line 29

def save
  @workers.save(self)
end