ast-tdl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ebd58255ecf60ba24423a07251499fb473c2751363795b9058a99a015a5efae
4
- data.tar.gz: f157c466e4feb81fa9ff3f50d65087f236c73083e854ed579f8a616888fa4c0b
3
+ metadata.gz: acbbd1f514fbcdc7f7c30925602170f3ebe829f688dbf3e562488f9fc88ed87f
4
+ data.tar.gz: 554f179dec696c7d330acb1884aed681f88f1a03923bd4353eef68bd9ddb2b81
5
5
  SHA512:
6
- metadata.gz: '08a3b71fd3c412338bb93d6c9aef954bd7a357e8e6dc190560b977ad7b7a0f9b4f4252ced3c5aedaf152ae3853023efc85b4663a2d60aaee24e264eab14ef6fa'
7
- data.tar.gz: 6a4a15557718d2abf418b9076f8075344d16308a2478e56a0c90deed727896ade8b539f69a1de270e77e3b0f8a75fb57433860747a5064d901e4479d4a53b341
6
+ metadata.gz: 2ffa95b47ee68c9091883a974fc84c3c91143594948bd22459a5d462209c877ee9f00919ca1e055b925d8ff35d8f6262f9f40f6e525b4cf9c8931d9827a923ec
7
+ data.tar.gz: 995761ca6d201f99b4cf9f3fc061279e5332b197b83161e52fa0792a7af3f1d7f4434f4eef4e3d9e3552fdb87cdda0881dd075d9fc380c07f10339d36b462e78
data/README.md CHANGED
@@ -1,33 +1,56 @@
1
1
  # Training Description Language (TDL) for Artificial Sport Trainer (AST)
2
-
3
- AST-DSL is a very small domain-specific language
4
-
5
- ## Objective
2
+ ast-dsl is intended to be a small DSL for practical definition and description of sports training that can be automatically or manually defined and used in conjunction with Artificial Sport Trainer.
6
3
 
7
4
  ## Installation
8
-
9
5
  $ gem install ast-tdl
10
6
 
11
7
  ## Language description
8
+ Training Description Language (TDL) is implemented in Ruby. Currently, the description of sports training sessions and intervals is now supported. Those contain various data, such as duration, average heart rate, sport type, and many more.
12
9
 
13
10
  ## Examples
11
+ ```ruby
12
+ EasyTraining = Ast.build :Monday do
13
+ session("Short swimming session today") {
14
+ sport :"swim"
15
+ info :"Very easy training"
16
+ average_heart_rate :"130"
17
+ total_duration :"30"
18
+ }
19
+
20
+ session("Bike ride") {
21
+ sport :"bike"
22
+ info :"Endurance ride with intervals"
23
+ average_heart_rate :"140"
24
+ total_duration :"250"
25
+ }
26
+
27
+ interval("Number 1") {
28
+ sport :"swim"
29
+ info :"Moderate"
30
+ average_heart_rate :"160"
31
+ total_duration :"5"
32
+ average_heart_rate_rest :"90"
33
+ total_duration_rest :"2"
34
+ }
35
+ end
36
+ ```
14
37
 
15
38
  ### Session
16
-
17
39
  ```ruby
18
40
  session("Short swimming session today") {
19
- sport :"swim"
20
- info :"Very easy training"
21
- avhr :"130"
22
- td :"30"
41
+ sport :"swim"
42
+ info :"Very easy training"
43
+ average_heart_rate :"130"
44
+ total_duration :"30"
23
45
  }
24
46
  ```
25
- ## License
26
47
 
48
+ ## License
27
49
  This package is distributed under the MIT License. This license can be found online at <http://www.opensource.org/licenses/MIT>.
28
50
 
29
51
  ## Disclaimer
30
-
31
52
  This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!
32
53
 
54
+ ## References
33
55
 
56
+ Fister Jr, I., Fister, I., Iglesias, A., Galvez, A., Deb, S., & Fister, D. (2021). On deploying the Artificial Sport Trainer into practice. arXiv preprint [arXiv:2109.13334](https://arxiv.org/abs/2109.13334).
data/lib/ast-tdl.rb CHANGED
@@ -1 +1,3 @@
1
- require_relative "./ast"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './ast'
data/lib/ast.rb CHANGED
@@ -1,86 +1,85 @@
1
- require "json"
2
-
3
- require_relative "classes"
4
- require_relative "interval"
5
- require_relative "session"
1
+ # frozen_string_literal: true
6
2
 
3
+ require 'json'
4
+ require_relative 'classes'
5
+ require_relative 'interval'
6
+ require_relative 'session'
7
7
 
8
8
  ##
9
9
  # This module is intended to be used for building trainings
10
10
  # from the domain specific language AST-TDL.
11
11
  module Ast
12
- ##
13
- # Building a new training from the domain specific language.
14
- # Params:
15
- # +name+:: the name of the training
16
- # +block+:: training data
17
- def self.build(name, &block)
18
- training = Training.new(name)
19
- training.instance_eval(&block)
20
- return training
21
- end
22
-
12
+ ##
13
+ # Building a new training from the domain specific language.
14
+ # Params:
15
+ # +name+:: the name of the training
16
+ # +block+:: training data
17
+ def self.build(name, &block)
18
+ training = Training.new(name)
19
+ training.instance_eval(&block)
20
+ training
21
+ end
23
22
 
24
- ##
25
- # This class represents a training with a name, sessions and intervals.
26
- class Training
27
- ##
28
- # Initialization method for the +Training+ class.
29
- # Params:
30
- # +name+:: the name of the training
31
- def initialize(name)
32
- @name = name
33
- @session = []
34
- @interval = []
35
- end
23
+ ##
24
+ # This class represents a training with a name, sessions and intervals.
25
+ class Training
26
+ ##
27
+ # Initialization method for the +Training+ class.
28
+ # Params:
29
+ # +name+:: the name of the training
30
+ def initialize(name)
31
+ @name = name
32
+ @session = []
33
+ @interval = []
34
+ end
36
35
 
37
- ##
38
- # Building a new session from the domain specific language.
39
- # Params:
40
- # +name+:: the name of the session
41
- # +block+:: session data
42
- def session(name, &block)
43
- training_type = Session.new(name)
44
- training_type.instance_eval(&block)
45
- @session << training_type
46
- end
36
+ ##
37
+ # Building a new session from the domain specific language.
38
+ # Params:
39
+ # +name+:: the name of the session
40
+ # +block+:: session data
41
+ def session(name, &block)
42
+ training_type = Session.new(name)
43
+ training_type.instance_eval(&block)
44
+ @session << training_type
45
+ end
47
46
 
48
- ##
49
- # Building a new interval from the domain specific language.
50
- # Params:
51
- # +name+:: the name of the interval
52
- # +block+:: interval data
53
- def interval(name, &block)
54
- interval_data = Interval.new(name)
55
- interval_data.instance_eval(&block)
56
- @interval << interval_data
57
- end
47
+ ##
48
+ # Building a new interval from the domain specific language.
49
+ # Params:
50
+ # +name+:: the name of the interval
51
+ # +block+:: interval data
52
+ def interval(name, &block)
53
+ interval_data = Interval.new(name)
54
+ interval_data.instance_eval(&block)
55
+ @interval << interval_data
56
+ end
58
57
 
59
- ##
60
- # Converting a training to a string.
61
- def to_s
62
- str = "#{@name} #{@session[0]}"
63
- end
58
+ ##
59
+ # Converting a training to a string.
60
+ def to_s
61
+ "#{@name} #{@session[0]}"
62
+ end
64
63
 
65
- ##
66
- # Converting a training to a JSON-ized string.
67
- def json
68
- training_json = {
69
- name: @name,
70
- session: @session.collect { |s| s.to_hash },
71
- interval: @interval.collect { |i| i.to_hash },
72
- }
73
- training_json.to_json
74
- end
64
+ ##
65
+ # Converting a training to a JSON-ized string.
66
+ def json
67
+ training_json = {
68
+ name: @name,
69
+ session: @session.collect(&:to_hash),
70
+ interval: @interval.collect(&:to_hash)
71
+ }
72
+ training_json.to_json
73
+ end
75
74
 
76
- ##
77
- # Saving a training to a JSON file.
78
- # Params:
79
- # +filename+:: the desired name of the file
80
- def save_to_file(filename)
81
- f = File.open(filename, "w")
82
- f.puts(json)
83
- f.close
84
- end
85
- end
75
+ ##
76
+ # Saving a training to a JSON file.
77
+ # Params:
78
+ # +filename+:: the desired name of the file
79
+ def save_to_file(filename)
80
+ f = File.open(filename, 'w')
81
+ f.puts(json)
82
+ f.close
83
+ end
84
+ end
86
85
  end
data/lib/classes.rb CHANGED
@@ -1,156 +1,148 @@
1
- require "json"
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'json'
3
4
 
4
5
  ##
5
6
  # This class represents a sport with a type.
6
7
  class Sport
7
- # The type of a sport.
8
- attr_reader :type
9
-
10
- ##
11
- # Initialization method for the +Sport+ class.
12
- # Params:
13
- # +type+:: the type of the sport
14
- def initialize(type)
15
- @type = type
16
- end
17
-
18
- ##
19
- # Converting +Sport+ class to a hash.
20
- def to_hash
21
- sport_json = {
22
- type: @type
23
- }
24
- end
8
+ # The type of a sport.
9
+ attr_reader :type
10
+
11
+ ##
12
+ # Initialization method for the +Sport+ class.
13
+ # Params:
14
+ # +type+:: the type of the sport
15
+ def initialize(type)
16
+ @type = type
17
+ end
18
+
19
+ ##
20
+ # Converting +Sport+ class to a hash.
21
+ def to_hash
22
+ {
23
+ type: @type
24
+ }
25
+ end
25
26
  end
26
27
 
27
-
28
28
  ##
29
29
  # This class represents information with a message.
30
30
  class Info
31
- # The info message.
32
- attr_reader :message
33
-
34
- ##
35
- # Initialization method for the +Info+ class.
36
- # Params:
37
- # +message+:: the info message
38
- def initialize(message)
39
- @message = message
40
- end
41
-
42
- ##
43
- # Converting +Info+ class to a hash.
44
- def to_hash
45
- info_json = {
46
- message: @message
47
- }
48
- end
31
+ # The info message.
32
+ attr_reader :message
33
+
34
+ ##
35
+ # Initialization method for the +Info+ class.
36
+ # Params:
37
+ # +message+:: the info message
38
+ def initialize(message)
39
+ @message = message
40
+ end
41
+
42
+ ##
43
+ # Converting +Info+ class to a hash.
44
+ def to_hash
45
+ {
46
+ message: @message
47
+ }
48
+ end
49
49
  end
50
50
 
51
-
52
51
  ##
53
52
  # This class represents an average heart rate.
54
53
  class AverageHeartRate
55
- # An average heart rate.
56
- attr_reader :heart_rate
57
-
58
- ##
59
- # Initialization method for the +AverageHeartRate+ class.
60
- # Params:
61
- # +heart_rate+:: the average heart rate
62
- def initialize(heart_rate)
63
- heart_rate = heart_rate.to_s.to_i
64
- if heart_rate > 220
65
- raise ArgumentError.new("Maximum heart rate is 220.")
66
- end
67
-
68
- @heart_rate = heart_rate
69
- end
70
-
71
- ##
72
- # Converting +AverageHeartRate+ class to a hash.
73
- def to_hash
74
- info_json = {
75
- average_hr: @heart_rate
76
- }
77
- end
54
+ # An average heart rate.
55
+ attr_reader :heart_rate
56
+
57
+ ##
58
+ # Initialization method for the +AverageHeartRate+ class.
59
+ # Params:
60
+ # +heart_rate+:: the average heart rate
61
+ def initialize(heart_rate)
62
+ heart_rate = heart_rate.to_s.to_i
63
+ raise ArgumentError, 'Maximum heart rate is 220.' if heart_rate > 220
64
+
65
+ @heart_rate = heart_rate
66
+ end
67
+
68
+ ##
69
+ # Converting +AverageHeartRate+ class to a hash.
70
+ def to_hash
71
+ {
72
+ average_hr: @heart_rate
73
+ }
74
+ end
78
75
  end
79
76
 
80
-
81
77
  ##
82
78
  # This class represents a total duration of a session or an interval.
83
79
  class TotalDuration
84
- # The total duration in seconds.
85
- attr_reader :duration
86
-
87
- ##
88
- # Initialization method for the +TotalDuration+ class.
89
- # Params:
90
- # +duration+:: the total duration
91
- def initialize(duration)
92
- @duration = duration
93
- end
94
-
95
- ##
96
- # Converting +TotalDuration+ class to a hash.
97
- def to_hash
98
- td_json = {
99
- duration: @duration
100
- }
101
- end
80
+ # The total duration in seconds.
81
+ attr_reader :duration
82
+
83
+ ##
84
+ # Initialization method for the +TotalDuration+ class.
85
+ # Params:
86
+ # +duration+:: the total duration
87
+ def initialize(duration)
88
+ @duration = duration
89
+ end
90
+
91
+ ##
92
+ # Converting +TotalDuration+ class to a hash.
93
+ def to_hash
94
+ {
95
+ duration: @duration
96
+ }
97
+ end
102
98
  end
103
99
 
104
-
105
100
  ##
106
101
  # This class represents an average heart rate in the resting period.
107
102
  class AverageHeartRateRest
108
- # The average rest heart rate.
109
- attr_reader :average_heart_rate_rest
110
-
111
- ##
112
- # Initialization method for the +AverageHeartRateRest+ class.
113
- # Params:
114
- # +average_heart_rate_rest+:: the average heart rate
115
- def initialize(average_heart_rate_rest)
116
- average_heart_rate_rest = average_heart_rate_rest.to_s.to_i
117
- if average_heart_rate_rest > 220
118
- raise ArgumentError.new("Maximum heart rate is 220.")
119
- end
120
-
121
- @average_heart_rate_rest = average_heart_rate_rest
122
- end
123
-
124
- ##
125
- # Converting +AverageHeartRateRest+ class to a hash.
126
- def to_hash
127
- average_heart_rate_json = {
128
- average_heart_rate_rest: @average_heart_rate_rest
129
- }
130
- end
103
+ # The average rest heart rate.
104
+ attr_reader :average_heart_rate_rest
105
+
106
+ ##
107
+ # Initialization method for the +AverageHeartRateRest+ class.
108
+ # Params:
109
+ # +average_heart_rate_rest+:: the average heart rate
110
+ def initialize(average_heart_rate_rest)
111
+ average_heart_rate_rest = average_heart_rate_rest.to_s.to_i
112
+ raise ArgumentError, 'Maximum heart rate is 220.' if average_heart_rate_rest > 220
113
+
114
+ @average_heart_rate_rest = average_heart_rate_rest
115
+ end
116
+
117
+ ##
118
+ # Converting +AverageHeartRateRest+ class to a hash.
119
+ def to_hash
120
+ {
121
+ average_heart_rate_rest: @average_heart_rate_rest
122
+ }
123
+ end
131
124
  end
132
125
 
133
-
134
126
  ##
135
127
  # This class represents a total duration of a session or an
136
128
  # interval in the resting period.
137
129
  class TotalDurationRest
138
- # The total duration in seconds.
139
- attr_reader :total_duration_rest
140
-
141
- ##
142
- # Initialization method for the +TotalDurationRest+ class.
143
- # Params:
144
- # +total_duration_rest+:: the total rest duration
145
- def initialize(total_duration_rest)
146
- @total_duration_rest = total_duration_rest
147
- end
148
-
149
- ##
150
- # Converting +TotalDurationRest+ class to a hash.
151
- def to_hash
152
- total_duration_rest_json = {
153
- total_duration_rest: @total_duration_rest
154
- }
155
- end
156
- end
130
+ # The total duration in seconds.
131
+ attr_reader :total_duration_rest
132
+
133
+ ##
134
+ # Initialization method for the +TotalDurationRest+ class.
135
+ # Params:
136
+ # +total_duration_rest+:: the total rest duration
137
+ def initialize(total_duration_rest)
138
+ @total_duration_rest = total_duration_rest
139
+ end
140
+
141
+ ##
142
+ # Converting +TotalDurationRest+ class to a hash.
143
+ def to_hash
144
+ {
145
+ total_duration_rest: @total_duration_rest
146
+ }
147
+ end
148
+ end
data/lib/interval.rb CHANGED
@@ -1,85 +1,87 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  # This class represents an interval.
3
5
  class Interval
4
- ##
5
- # Initialization method for the +Interval+ class.
6
- # Params:
7
- # +name+:: the name of the interval
8
- def initialize(name)
9
- @name = []
10
- @sport = []
11
- @info = []
12
- @average_heart_rate = []
13
- @total_duration = []
14
- @average_heart_rate_rest = []
15
- @total_duration_rest = []
16
- end
6
+ ##
7
+ # Initialization method for the +Interval+ class.
8
+ # Params:
9
+ # +name+:: the name of the interval
10
+ def initialize(_name)
11
+ @name = []
12
+ @sport = []
13
+ @info = []
14
+ @average_heart_rate = []
15
+ @total_duration = []
16
+ @average_heart_rate_rest = []
17
+ @total_duration_rest = []
18
+ end
19
+
20
+ ##
21
+ # Building a new Sport object.
22
+ # Params:
23
+ # +type+:: the type of the sport
24
+ def sport(type)
25
+ @sport << Sport.new(type)
26
+ end
27
+
28
+ ##
29
+ # Building a new Info object.
30
+ # Params:
31
+ # +message+:: the info message
32
+ def info(message)
33
+ @info << Info.new(message)
34
+ end
35
+
36
+ ##
37
+ # Building a new AverageHeartRate object.
38
+ # Params:
39
+ # +heart_rate+:: the average heart rate in bpm
40
+ def average_heart_rate(heart_rate)
41
+ @average_heart_rate << AverageHeartRate.new(heart_rate)
42
+ end
17
43
 
18
- ##
19
- # Building a new Sport object.
20
- # Params:
21
- # +type+:: the type of the sport
22
- def sport(type)
23
- @sport << Sport.new(type)
24
- end
44
+ ##
45
+ # Building a new TotalDuration object.
46
+ # Params:
47
+ # +duration+:: the duration in seconds
48
+ def total_duration(duration)
49
+ @total_duration << TotalDuration.new(duration)
50
+ end
25
51
 
26
- ##
27
- # Building a new Info object.
28
- # Params:
29
- # +message+:: the info message
30
- def info(message)
31
- @info << Info.new(message)
32
- end
52
+ ##
53
+ # Building a new AverageHeartRateRest object.
54
+ # Params:
55
+ # +heart_rate_rest+:: the average rest heart rate in bpm
56
+ def average_heart_rate_rest(heart_rate_rest)
57
+ @average_heart_rate_rest << AverageHeartRateRest.new(heart_rate_rest)
58
+ end
33
59
 
34
- ##
35
- # Building a new AverageHeartRate object.
36
- # Params:
37
- # +heart_rate+:: the average heart rate in bpm
38
- def average_heart_rate(heart_rate)
39
- @average_heart_rate << AverageHeartRate.new(heart_rate)
40
- end
60
+ ##
61
+ # Building a new TotalDurationRest object.
62
+ # Params:
63
+ # +duration rest+:: the rest duration in seconds
64
+ def total_duration_rest(duration_rest)
65
+ @total_duration_rest << TotalDurationRest.new(duration_rest)
66
+ end
41
67
 
42
- ##
43
- # Building a new TotalDuration object.
44
- # Params:
45
- # +duration+:: the duration in seconds
46
- def total_duration(duration)
47
- @total_duration << TotalDuration.new(duration)
48
- end
49
-
50
- ##
51
- # Building a new AverageHeartRateRest object.
52
- # Params:
53
- # +heart_rate_rest+:: the average rest heart rate in bpm
54
- def average_heart_rate_rest(heart_rate_rest)
55
- @average_heart_rate_rest << AverageHeartRateRest.new(heart_rate_rest)
56
- end
57
-
58
- ##
59
- # Building a new TotalDurationRest object.
60
- # Params:
61
- # +duration rest+:: the rest duration in seconds
62
- def total_duration_rest(duration_rest)
63
- @total_duration_rest << TotalDurationRest.new(duration_rest)
64
- end
65
-
66
- ##
67
- # Converting an interval to a string.
68
- def to_s
69
- str = "#{@sport[0].type} #{@info[0].message}"
70
- end
68
+ ##
69
+ # Converting an interval to a string.
70
+ def to_s
71
+ "#{@sport[0].type} #{@info[0].message}"
72
+ end
71
73
 
72
- ##
73
- # Converting an interval to a JSON-ized string.
74
- def to_hash
75
- interval_json = {
76
- name: @name.collect { |x| x.to_hash },
77
- sport: @sport.collect { |x| x.to_hash },
78
- info: @info.collect { |x| x.to_hash },
79
- average_heart_rate: @average_heart_rate.collect { |x| x.to_hash },
80
- total_duration: @total_duration.collect { |x| x.to_hash },
81
- average_heart_rate_rest: @average_heart_rate_rest.collect { |x| x.to_hash },
82
- total_duration_rest: @total_duration_rest.collect { |x| x.to_hash },
83
- }
84
- end
85
- end
74
+ ##
75
+ # Converting an interval to a JSON-ized string.
76
+ def to_hash
77
+ {
78
+ name: @name.collect(&:to_hash),
79
+ sport: @sport.collect(&:to_hash),
80
+ info: @info.collect(&:to_hash),
81
+ average_heart_rate: @average_heart_rate.collect(&:to_hash),
82
+ total_duration: @total_duration.collect(&:to_hash),
83
+ average_heart_rate_rest: @average_heart_rate_rest.collect(&:to_hash),
84
+ total_duration_rest: @total_duration_rest.collect(&:to_hash),
85
+ }
86
+ end
87
+ end
data/lib/session.rb CHANGED
@@ -1,65 +1,67 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  # This class represents a session.
3
5
  class Session
4
- ##
5
- # Initialization method for the +Session+ class.
6
- # Params:
7
- # +name+:: the name of the session
8
- def initialize(name)
9
- @name = []
10
- @sport = []
11
- @info = []
12
- @average_heart_rate = []
13
- @total_duration = []
14
- end
6
+ ##
7
+ # Initialization method for the +Session+ class.
8
+ # Params:
9
+ # +name+:: the name of the session
10
+ def initialize(_name)
11
+ @name = []
12
+ @sport = []
13
+ @info = []
14
+ @average_heart_rate = []
15
+ @total_duration = []
16
+ end
15
17
 
16
- ##
17
- # Building a new Sport object.
18
- # Params:
19
- # +type+:: the type of the sport
20
- def sport(type)
21
- @sport << Sport.new(type)
22
- end
18
+ ##
19
+ # Building a new Sport object.
20
+ # Params:
21
+ # +type+:: the type of the sport
22
+ def sport(type)
23
+ @sport << Sport.new(type)
24
+ end
23
25
 
24
- ##
25
- # Building a new Info object.
26
- # Params:
27
- # +message+:: the info message
28
- def info(message)
29
- @info << Info.new(message)
30
- end
26
+ ##
27
+ # Building a new Info object.
28
+ # Params:
29
+ # +message+:: the info message
30
+ def info(message)
31
+ @info << Info.new(message)
32
+ end
31
33
 
32
- ##
33
- # Building a new AverageHeartRate object.
34
- # Params:
35
- # +heart_rate+:: the average heart rate in bpm
36
- def average_heart_rate(heart_rate)
37
- @average_heart_rate << AverageHeartRate.new(heart_rate)
38
- end
34
+ ##
35
+ # Building a new AverageHeartRate object.
36
+ # Params:
37
+ # +heart_rate+:: the average heart rate in bpm
38
+ def average_heart_rate(heart_rate)
39
+ @average_heart_rate << AverageHeartRate.new(heart_rate)
40
+ end
39
41
 
40
- ##
41
- # Building a new TotalDuration object.
42
- # Params:
43
- # +duration+:: the duration in seconds
44
- def total_duration(duration)
45
- @total_duration << TotalDuration.new(duration)
46
- end
42
+ ##
43
+ # Building a new TotalDuration object.
44
+ # Params:
45
+ # +duration+:: the duration in seconds
46
+ def total_duration(duration)
47
+ @total_duration << TotalDuration.new(duration)
48
+ end
47
49
 
48
- ##
49
- # Converting a session to a string.
50
- def to_s
51
- str = "#{@sport[0].type} #{@info[0].message}"
52
- end
50
+ ##
51
+ # Converting a session to a string.
52
+ def to_s
53
+ "#{@sport[0].type} #{@info[0].message}"
54
+ end
53
55
 
54
- ##
55
- # Converting a session to a JSON-ized string.
56
- def to_hash
57
- session_json = {
58
- name: @name.collect { |x| x.to_hash },
59
- sport: @sport.collect { |x| x.to_hash },
60
- info: @info.collect { |x| x.to_hash },
61
- average_heart_rate: @average_heart_rate.collect { |x| x.to_hash },
62
- total_duration: @total_duration.collect { |x| x.to_hash },
63
- }
64
- end
65
- end
56
+ ##
57
+ # Converting a session to a JSON-ized string.
58
+ def to_hash
59
+ {
60
+ name: @name.collect(&:to_hash),
61
+ sport: @sport.collect(&:to_hash),
62
+ info: @info.collect(&:to_hash),
63
+ average_heart_rate: @average_heart_rate.collect(&:to_hash),
64
+ total_duration: @total_duration.collect(&:to_hash),
65
+ }
66
+ end
67
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ast-tdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - firefly-cpp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-14 00:00:00.000000000 Z
12
+ date: 2022-06-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -25,12 +25,13 @@ files:
25
25
  - lib/classes.rb
26
26
  - lib/interval.rb
27
27
  - lib/session.rb
28
- homepage: https://github.com/firefly-cpp/AST-DSL
29
- licenses: []
28
+ homepage: https://github.com/firefly-cpp/ast-tdl
29
+ licenses:
30
+ - MIT
30
31
  metadata:
31
- homepage_uri: https://github.com/firefly-cpp/AST-DSL
32
- source_code_uri: https://github.com/firefly-cpp/AST-DSL
33
- changelog_uri: https://github.com/firefly-cpp/AST-DSL
32
+ homepage_uri: https://github.com/firefly-cpp/ast-tdl
33
+ source_code_uri: https://github.com/firefly-cpp/ast-tdl
34
+ changelog_uri: https://github.com/firefly-cpp/ast-tdl
34
35
  post_install_message:
35
36
  rdoc_options: []
36
37
  require_paths:
@@ -39,7 +40,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
40
  requirements:
40
41
  - - ">="
41
42
  - !ruby/object:Gem::Version
42
- version: 2.4.0
43
+ version: 2.6.0
43
44
  required_rubygems_version: !ruby/object:Gem::Requirement
44
45
  requirements:
45
46
  - - ">="