Class: ChatWorkToSlack::Client
- Inherits:
-
Object
- Object
- ChatWorkToSlack::Client
- Defined in:
- lib/chatwork_to_slack.rb
Instance Attribute Summary collapse
-
#chatwork_api_key ⇒ Object
readonly
Returns the value of attribute chatwork_api_key.
-
#chatwork_csv_path ⇒ Object
readonly
Returns the value of attribute chatwork_csv_path.
-
#room_id ⇒ Object
readonly
Returns the value of attribute room_id.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
-
#workdir ⇒ Object
readonly
Returns the value of attribute workdir.
Instance Method Summary collapse
- #generate_template ⇒ Object
-
#initialize(args) ⇒ Client
constructor
A new instance of Client.
- #to_csv ⇒ Object
Constructor Details
#initialize(args) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 |
# File 'lib/chatwork_to_slack.rb', line 11 def initialize(args) @room_id = args[:room_id] @channel = args[:channel] @workdir = args[:workdir] @users = args[:users] @chatwork_csv_path = args[:chatwork_csv_path] @chatwork_api_key = args[:chatwork_api_key] end |
Instance Attribute Details
#chatwork_api_key ⇒ Object (readonly)
Returns the value of attribute chatwork_api_key.
9 10 11 |
# File 'lib/chatwork_to_slack.rb', line 9 def chatwork_api_key @chatwork_api_key end |
#chatwork_csv_path ⇒ Object (readonly)
Returns the value of attribute chatwork_csv_path.
9 10 11 |
# File 'lib/chatwork_to_slack.rb', line 9 def chatwork_csv_path @chatwork_csv_path end |
#room_id ⇒ Object (readonly)
Returns the value of attribute room_id.
9 10 11 |
# File 'lib/chatwork_to_slack.rb', line 9 def room_id @room_id end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
9 10 11 |
# File 'lib/chatwork_to_slack.rb', line 9 def users @users end |
#workdir ⇒ Object (readonly)
Returns the value of attribute workdir.
9 10 11 |
# File 'lib/chatwork_to_slack.rb', line 9 def workdir @workdir end |
Instance Method Details
#generate_template ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/chatwork_to_slack.rb', line 32 def generate_template CSV.generate do |csv| csv << ['chatwork_account_id', 'chatwork_name', 'slack_name'] chatwork_users.each do |u| csv << [u['account_id'], u['name'], u['chatwork_id']] end end end |
#to_csv ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chatwork_to_slack.rb', line 20 def to_csv invalid_users.each do |name| puts "[WARN] #{name} is not valid slack username" end CSV.generate do |csv| .each do || csv << end end end |