stock_gem 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stock_gem.rb +29 -24
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bc79add6a0145ecefa31294cfdf3e08c95e34a61713c955ad744a2817c3c8c5
4
- data.tar.gz: 706859fb94adc18a565e8a8d5e8bec82cefd9088b95f506e57c2971924349788
3
+ metadata.gz: b91836bba04d44cb523087814bd2168372a4af22fb0d800515231ff89b875314
4
+ data.tar.gz: a3e317aa54d4ab60f976d26ff6a2a5dc7b758df558f42d9893d0eacb7dd8a904
5
5
  SHA512:
6
- metadata.gz: 28a29f1e36d7dc7d489afeb5748e51d6d8babc139b3b86d3755a97dc13dc52d3b544a74f6291577c65a879141086b51c749430221bd1d15155f7f6576ef366b5
7
- data.tar.gz: 16a7bc8b298d645c0de35d296b3cb5d644114f683d9291f14babab9cd47c1a494616c82a968a555b76fe12bed65c6c03033c545217cdb1b10ba3926734580dd3
6
+ metadata.gz: f39ad86b77b173baada904d995241c6034846a99a7de04f9f935fb9bf9f3b59bada849404d977dec1dc74dc63cf3cf804b6b4e06ba9f1de67c9571f5c510031e
7
+ data.tar.gz: 78f5e1cb594cb55a4884b24d694b1ecfce4c4cabd0e54e017dd36945783eb84c017403089bf2c442ab504f63dc6388e3fb38cec0ab2b0f8ec7c244ee99e1dd95
data/lib/stock_gem.rb CHANGED
@@ -3,31 +3,36 @@
3
3
  require 'net/http'
4
4
  require 'open-uri'
5
5
  require 'nokogiri'
6
+ module StockGem
7
+ class Stock
8
+ def self.print_stock
9
+ prefix = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
+ prefix_list = prefix.split("")
11
+ prefix_list.each do |prefix|
12
+ pre_url = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='+prefix
13
+ document = open(pre_url)
14
+ content = document.read
15
+ parsed_content = Nokogiri::HTML(content)
6
16
 
7
- prefix = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
8
- prefix_list = prefix.split("")
9
- prefix_list.each do |prefix|
10
- pre_url = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='+prefix
11
- document = open(pre_url)
12
- content = document.read
13
- parsed_content = Nokogiri::HTML(content)
17
+ a = parsed_content.css('table.table-profile.table-hover.table-set-border-yellow').css('a')
18
+ a.each do |link|
19
+ sub_link = link['href']
20
+ link = 'https://www.set.or.th/' + sub_link
21
+ document = open(link)
22
+ content = document.read
23
+ parsed_content = Nokogiri::HTML(content)
24
+ com_name = parsed_content.xpath('//*[@id="maincontent"]/div/div[1]/div[1]/h3').text
14
25
 
15
- a = parsed_content.css('table.table-profile.table-hover.table-set-border-yellow').css('a')
16
- a.each do |link|
17
- sub_link = link['href']
18
- link = 'https://www.set.or.th/' + sub_link
19
- document = open(link)
20
- content = document.read
21
- parsed_content = Nokogiri::HTML(content)
22
- com_name = parsed_content.xpath('//*[@id="maincontent"]/div/div[1]/div[1]/h3').text
26
+ sub_link.gsub!('companyprofile', 'companyhighlight')
27
+ link = 'https://www.set.or.th/' + sub_link
28
+ document = open(link)
29
+ content = document.read
30
+ parsed_content = Nokogiri::HTML(content)
31
+ money = parsed_content.xpath('//*[@id="maincontent"]/div/div[4]/table/tbody[1]/tr[2]/td[5]').text
23
32
 
24
- sub_link.gsub!('companyprofile', 'companyhighlight')
25
- link = 'https://www.set.or.th/' + sub_link
26
- document = open(link)
27
- content = document.read
28
- parsed_content = Nokogiri::HTML(content)
29
- money = parsed_content.xpath('//*[@id="maincontent"]/div/div[4]/table/tbody[1]/tr[2]/td[5]').text
30
-
31
- puts result = com_name + ' : ' + money
33
+ puts result = com_name + ' : ' + money
34
+ end
35
+ end
36
+ end
37
+ end
32
38
  end
33
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stock_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bhatara Chaemchan SKE17