Last active
August 3, 2016 09:40
-
-
Save borntyping/2b06c7960132c918ecce5c09cd027b69 to your computer and use it in GitHub Desktop.
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
class TimePeriod | |
attr_accessor :seconds | |
def hours | |
seconds / 3600 | |
end | |
def hours=(value) | |
seconds = value * 3600 | |
hours | |
end | |
end | |
t = TimePeriod.new | |
t.hours = 24 | |
puts "Time in hours: #{t.hours}" |
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
class TimePeriod() { | |
var seconds = 0 | |
// Getter | |
def hours = seconds / 3600 | |
// Setter | |
def hours_= (value:Int):Unit = _seconds = value * 3600 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment