ast-tdl 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ast.rb +1 -2
- data/lib/interval.rb +50 -37
- data/lib/session.rb +24 -22
- metadata +2 -3
- data/lib/classes.rb +0 -148
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80f5ce52b90eddc0e2a1d7500a9cb72266cbb9942b48abe51452fc0e5772ed7
|
4
|
+
data.tar.gz: '019b6ee3ace2a1bf5075f4eda8bbde0e84fd01ad76edef4c8e449d91feefb6a7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c63722d51efd64fe0ec516b3861668ea5a9ba96dbb0b4449822ad7b3b0db96922d73addcc6a69fb28de517a608e13f05ccf57a27f15483f87263a97350feb0d
|
7
|
+
data.tar.gz: 8696fbc00936ba6fe0a533aa5f70e5745d96ba7b9f189267a7d3b40763262477348fede00c69b5de8a214db99850bce9fcb5b64d12ef339df35a4c0b686f094b
|
data/lib/ast.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
-
require_relative 'classes'
|
5
4
|
require_relative 'interval'
|
6
5
|
require_relative 'session'
|
7
6
|
|
@@ -69,7 +68,7 @@ module Ast
|
|
69
68
|
session: @session.collect(&:to_hash),
|
70
69
|
interval: @interval.collect(&:to_hash)
|
71
70
|
}
|
72
|
-
training_json
|
71
|
+
JSON.pretty_generate(training_json)
|
73
72
|
end
|
74
73
|
|
75
74
|
##
|
data/lib/interval.rb
CHANGED
@@ -7,81 +7,94 @@ class Interval
|
|
7
7
|
# Initialization method for the +Interval+ class.
|
8
8
|
# Params:
|
9
9
|
# +name+:: the name of the interval
|
10
|
-
def initialize(
|
11
|
-
@name =
|
12
|
-
@sport =
|
13
|
-
@info =
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
10
|
+
def initialize(name)
|
11
|
+
@name = name
|
12
|
+
@sport = ''
|
13
|
+
@info = ''
|
14
|
+
@speed_duration = 0
|
15
|
+
@recovery_duration = 0
|
16
|
+
@speed_heart_rate = 0
|
17
|
+
@recovery_heart_rate = 0
|
18
|
+
@repetitions = 0
|
18
19
|
end
|
19
20
|
|
20
21
|
##
|
21
|
-
#
|
22
|
+
# Adding a sport to the object.
|
22
23
|
# Params:
|
23
24
|
# +type+:: the type of the sport
|
24
25
|
def sport(type)
|
25
|
-
@sport
|
26
|
+
@sport = type
|
26
27
|
end
|
27
28
|
|
28
29
|
##
|
29
|
-
#
|
30
|
+
# Adding an info message to the object.
|
30
31
|
# Params:
|
31
32
|
# +message+:: the info message
|
32
33
|
def info(message)
|
33
|
-
@info
|
34
|
+
@info = message
|
34
35
|
end
|
35
36
|
|
36
37
|
##
|
37
|
-
#
|
38
|
+
# Adding a speed duration of an interval to the object.
|
38
39
|
# Params:
|
39
|
-
# +
|
40
|
-
def
|
41
|
-
@
|
40
|
+
# +speed_duration+:: the duration of the speed segment in minutes
|
41
|
+
def speed_duration(speed_duration)
|
42
|
+
@speed_duration = speed_duration.to_s.to_i
|
42
43
|
end
|
43
44
|
|
44
45
|
##
|
45
|
-
#
|
46
|
+
# Adding a recovery duration of an interval to the object.
|
46
47
|
# Params:
|
47
|
-
# +
|
48
|
-
def
|
49
|
-
@
|
48
|
+
# +recovery_duration+:: the duration of the recovery segment in minutes
|
49
|
+
def recovery_duration(recovery_duration)
|
50
|
+
@recovery_duration = recovery_duration.to_s.to_i
|
50
51
|
end
|
51
52
|
|
52
53
|
##
|
53
|
-
#
|
54
|
+
# Adding a speed heart rate of an interval to the object.
|
54
55
|
# Params:
|
55
|
-
# +
|
56
|
-
def
|
57
|
-
@
|
56
|
+
# +speed_heart_rate+:: the average speed heart rate in bpm
|
57
|
+
def speed_heart_rate(speed_heart_rate)
|
58
|
+
@speed_heart_rate = speed_heart_rate.to_s.to_i
|
58
59
|
end
|
59
60
|
|
60
61
|
##
|
61
|
-
#
|
62
|
+
# Adding a recovery heart rate of an interval to the object.
|
62
63
|
# Params:
|
63
|
-
# +
|
64
|
-
def
|
65
|
-
@
|
64
|
+
# +recovery_heart_rate+:: the average speed heart rate in bpm
|
65
|
+
def recovery_heart_rate(recovery_heart_rate)
|
66
|
+
@recovery_heart_rate = recovery_heart_rate.to_s.to_i
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Adding a number of repetitions to the object.
|
71
|
+
# Params:
|
72
|
+
# +repetitions+:: number of interval repetitions
|
73
|
+
def repetitions(repetitions)
|
74
|
+
@repetitions = repetitions.to_s.to_i
|
66
75
|
end
|
67
76
|
|
68
77
|
##
|
69
78
|
# Converting an interval to a string.
|
70
79
|
def to_s
|
71
|
-
"#{@sport
|
80
|
+
"#{@sport} #{@info}"
|
72
81
|
end
|
73
82
|
|
74
83
|
##
|
75
84
|
# Converting an interval to a JSON-ized string.
|
76
85
|
def to_hash
|
77
|
-
{
|
78
|
-
name: @name
|
79
|
-
sport: @sport
|
80
|
-
info: @info
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
86
|
+
hash = {
|
87
|
+
name: @name,
|
88
|
+
sport: @sport,
|
89
|
+
info: @info,
|
90
|
+
speed_duration: @speed_duration,
|
91
|
+
recovery_duration: @recovery_duration,
|
92
|
+
speed_heart_rate: @speed_heart_rate,
|
93
|
+
recovery_heart_rate: @recovery_heart_rate,
|
94
|
+
repetitions: @repetitions
|
85
95
|
}
|
96
|
+
|
97
|
+
hash[:info] = @info if @info
|
98
|
+
hash
|
86
99
|
end
|
87
100
|
end
|
data/lib/session.rb
CHANGED
@@ -7,61 +7,63 @@ class Session
|
|
7
7
|
# Initialization method for the +Session+ class.
|
8
8
|
# Params:
|
9
9
|
# +name+:: the name of the session
|
10
|
-
def initialize(
|
11
|
-
@name =
|
12
|
-
@sport =
|
13
|
-
@info =
|
14
|
-
@average_heart_rate =
|
15
|
-
@total_duration =
|
10
|
+
def initialize(name)
|
11
|
+
@name = name
|
12
|
+
@sport = ''
|
13
|
+
@info = ''
|
14
|
+
@average_heart_rate = 0
|
15
|
+
@total_duration = 0
|
16
16
|
end
|
17
17
|
|
18
18
|
##
|
19
|
-
#
|
19
|
+
# Adding a sport type to the object.
|
20
20
|
# Params:
|
21
21
|
# +type+:: the type of the sport
|
22
22
|
def sport(type)
|
23
|
-
@sport
|
23
|
+
@sport = type
|
24
24
|
end
|
25
25
|
|
26
26
|
##
|
27
|
-
#
|
27
|
+
# Adding a message to the object.
|
28
28
|
# Params:
|
29
29
|
# +message+:: the info message
|
30
30
|
def info(message)
|
31
|
-
@info
|
31
|
+
@info = message
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
35
|
-
#
|
35
|
+
# Adding an average heart rate to the object.
|
36
36
|
# Params:
|
37
37
|
# +heart_rate+:: the average heart rate in bpm
|
38
38
|
def average_heart_rate(heart_rate)
|
39
|
-
@average_heart_rate
|
39
|
+
@average_heart_rate = heart_rate.to_s.to_i
|
40
40
|
end
|
41
41
|
|
42
42
|
##
|
43
|
-
#
|
43
|
+
# Adding a total duration to the object.
|
44
44
|
# Params:
|
45
|
-
# +duration+:: the duration in
|
45
|
+
# +duration+:: the duration in minutes
|
46
46
|
def total_duration(duration)
|
47
|
-
@total_duration
|
47
|
+
@total_duration = duration.to_s.to_i
|
48
48
|
end
|
49
49
|
|
50
50
|
##
|
51
51
|
# Converting a session to a string.
|
52
52
|
def to_s
|
53
|
-
"#{@sport
|
53
|
+
"#{@sport} #{@info}"
|
54
54
|
end
|
55
55
|
|
56
56
|
##
|
57
57
|
# Converting a session to a JSON-ized string.
|
58
58
|
def to_hash
|
59
|
-
{
|
60
|
-
name: @name
|
61
|
-
sport: @sport
|
62
|
-
|
63
|
-
|
64
|
-
total_duration: @total_duration.collect(&:to_hash),
|
59
|
+
hash = {
|
60
|
+
name: @name,
|
61
|
+
sport: @sport,
|
62
|
+
average_heart_rate: @average_heart_rate,
|
63
|
+
total_duration: @total_duration,
|
65
64
|
}
|
65
|
+
|
66
|
+
hash[:info] = @info if @info != ''
|
67
|
+
hash
|
66
68
|
end
|
67
69
|
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
|
4
|
+
version: 0.1.0
|
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-
|
12
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -23,7 +23,6 @@ files:
|
|
23
23
|
- README.md
|
24
24
|
- lib/ast-tdl.rb
|
25
25
|
- lib/ast.rb
|
26
|
-
- lib/classes.rb
|
27
26
|
- lib/interval.rb
|
28
27
|
- lib/session.rb
|
29
28
|
homepage: https://github.com/firefly-cpp/ast-tdl
|
data/lib/classes.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
##
|
6
|
-
# This class represents a sport with a type.
|
7
|
-
class Sport
|
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
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# This class represents information with a message.
|
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
|
-
{
|
46
|
-
message: @message
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
##
|
52
|
-
# This class represents an average heart rate.
|
53
|
-
class AverageHeartRate
|
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
|
75
|
-
end
|
76
|
-
|
77
|
-
##
|
78
|
-
# This class represents a total duration of a session or an interval.
|
79
|
-
class TotalDuration
|
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
|
98
|
-
end
|
99
|
-
|
100
|
-
##
|
101
|
-
# This class represents an average heart rate in the resting period.
|
102
|
-
class AverageHeartRateRest
|
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
|
124
|
-
end
|
125
|
-
|
126
|
-
##
|
127
|
-
# This class represents a total duration of a session or an
|
128
|
-
# interval in the resting period.
|
129
|
-
class TotalDurationRest
|
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
|