Class: StudyLine::CLI
- Inherits:
-
Thor
- Object
- Thor
- StudyLine::CLI
- Defined in:
- lib/study_line.rb
Defined Under Namespace
Classes: Sender
Instance Method Summary collapse
Instance Method Details
#configure(token) ⇒ Object
12 13 14 15 16 |
# File 'lib/study_line.rb', line 12 def configure(token) config = { 'CUSTOM_TOKEN' => token } File.write(CONFIG_FILE, config.to_json) puts "トークンが設定されました。" end |
#finish ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/study_line.rb', line 43 def finish finish_time = Time.now response = Sender.post( "#{Sender::BASE_URI}/update", body: { finish_time: finish_time }.to_json, headers: headers ) # Handle the response... if response.success? puts "学習の終了時間を記録します。" else = response.parsed_response['message'] || 'Unknown error' puts "Error: #{}" end end |
#show ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/study_line.rb', line 61 def show if File.exist?(CONFIG_FILE) config = JSON.parse(File.read(CONFIG_FILE)) puts "現在のCUSTOM_TOKEN: #{config['CUSTOM_TOKEN'] || '未設定'}" else puts "トークンは未設定です。" end end |
#start ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/study_line.rb', line 25 def start start_time = Time.now = [:tag] ? [:tag].split(',') : [] response = Sender.post( "#{Sender::BASE_URI}/create", body: { start_time: start_time, tags: }.to_json, headers: headers ) # Handle the response... if response.success? puts "学習セッションの開始に成功しました。" else = response.parsed_response['error'] || response.parsed_response['message'] || 'Unknown error' puts "Error: #{response['error']}" end end |