Skip to content

Commit 7fb55b4

Browse files
committed
doc: Add doc strings
1 parent 7943683 commit 7fb55b4

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

changes.patch

9.91 KB
Binary file not shown.

lib/optimizely/custom_attribute_condition_evaluator.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,34 +273,54 @@ def substring_evaluator(condition)
273273
end
274274

275275
def semver_equal_evaluator(condition)
276+
# Evaluate the given semantic version equal match target version for the user version.
277+
# Returns boolean true if the user version is equal to the target version,
278+
# false if the user version is not equal to the target version
279+
276280
target_version = condition['value']
277281
user_version = @user_attributes[condition['name']]
278282

279283
SemanticVersion.compare_user_version_with_target_version(target_version, user_version).zero?
280284
end
281285

282286
def semver_greater_than_evaluator(condition)
287+
# Evaluate the given semantic version greater than match target version for the user version.
288+
# Returns boolean true if the user version is greater than the target version,
289+
# false if the user version is less than or equal to the target version
290+
283291
target_version = condition['value']
284292
user_version = @user_attributes[condition['name']]
285293

286294
SemanticVersion.compare_user_version_with_target_version(target_version, user_version).positive?
287295
end
288296

289297
def semver_greater_than_or_equal_evaluator(condition)
298+
# Evaluate the given semantic version greater than or equal to match target version for the user version.
299+
# Returns boolean true if the user version is greater than or equal to the target version,
300+
# false if the user version is less than the target version
301+
290302
target_version = condition['value']
291303
user_version = @user_attributes[condition['name']]
292304

293305
SemanticVersion.compare_user_version_with_target_version(target_version, user_version) >= 0
294306
end
295307

296308
def semver_less_than_evaluator(condition)
309+
# Evaluate the given semantic version less than match target version for the user version.
310+
# Returns boolean true if the user version is less than the target version,
311+
# false if the user version is greater than or equal to the target version
312+
297313
target_version = condition['value']
298314
user_version = @user_attributes[condition['name']]
299315

300316
SemanticVersion.compare_user_version_with_target_version(target_version, user_version).negative?
301317
end
302318

303319
def semver_less_than_or_equal_evaluator(condition)
320+
# Evaluate the given semantic version less than or equal to match target version for the user version.
321+
# Returns boolean true if the user version is less than or equal to the target version,
322+
# false if the user version is greater than the target version
323+
304324
target_version = condition['value']
305325
user_version = @user_attributes[condition['name']]
306326

lib/optimizely/semantic_version.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,24 @@ module SemanticVersion
2727
module_function
2828

2929
def pre_release?(target)
30+
# Method to check if the given version contains "-"
31+
#
32+
# target - String representing semantic version
33+
#
34+
# Returns true if the given version does contain "-"
35+
# false if it doesn't
36+
3037
target.include? SEMVER_PRE_RELEASE
3138
end
3239

3340
def split_semantic_version(target)
41+
# Method to split the given version.
42+
#
43+
# target - String representing semantic version
44+
#
45+
# Returns List The array of version split into smaller parts i.e major, minor, patch etc,
46+
# Exception if the given version is invalid.
47+
3448
target_prefix = target
3549
target_suffix = ''
3650
target_parts = []
@@ -65,6 +79,15 @@ def split_semantic_version(target)
6579
end
6680

6781
def compare_user_version_with_target_version(target_version, user_version)
82+
# Compares target and user versions
83+
#
84+
# target_version - String representing target version
85+
# user_version - String representing user version
86+
87+
# Returns boolean 0 if user version is equal to target version,
88+
# 1 if user version is greater than target version,
89+
# -1 if user version is less than target version.
90+
6891
raise InvalidAttributeType unless target_version.is_a? String
6992
raise InvalidAttributeType unless user_version.is_a? String
7093

0 commit comments

Comments
 (0)