-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c868e10
commit 2409971
Showing
5 changed files
with
91 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
module Rtasklib | ||
|
||
module Helpers | ||
# make this module a stateless, singleton | ||
extend self | ||
|
||
# Int needs to precede float because ints are also floats | ||
def determine_type value | ||
if boolean? value | ||
return Axiom::Types::Boolean | ||
elsif integer? value | ||
return Integer | ||
elsif float? value | ||
return Float | ||
else | ||
return String | ||
end | ||
end | ||
|
||
def integer? value | ||
value.to_i.to_s == value | ||
end | ||
|
||
def float? value | ||
Float(value) rescue false | ||
end | ||
|
||
def boolean? value | ||
["on", "off", "yes", "no", "false", "true"].include? value.to_s.downcase | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters