This file contains hidden or 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
| #test_ruby_class.rb | |
| class TestRubyClass | |
| attr_accessor :name, :birth_year | |
| def initialize | |
| @name = 'Yukihiro Matsumoto' | |
| @birth_year = 1965 | |
| end |
This file contains hidden or 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
| def average(array) | |
| array.inject(0) { |memo, element| memo += element } / array.size | |
| end | |
| def calculate_deviation(value, average) | |
| value >= 0 ? value - average : average - value | |
| end | |
| def solution(a) |
This file contains hidden or 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
| def average(array) | |
| array.inject(0) { |memo, element| memo += element } / array.size | |
| end | |
| def calculate_deviation(value, average) | |
| value >= 0 ? value - average : average - value | |
| end | |
| def solution(a) | |
| extreme_element_index = -1 |
This file contains hidden or 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
| // Quite different to ruby. Took me a little longer to find out how to do it than it should. | |
| def template(filename) { | |
| def input = getClass().getResourceAsStream("/path/to/package/${filename}.template") | |
| new InputStreamReader(input, 'utf-8') | |
| } | |
| // If file is in your 'resources' folder then use the below | |
| def templateFromResources(filename){ | |
| def input = getClass().getResourceAsStream("templates/${filename}.template") | |
| new InputStreamReader(input, 'utf-8') |
This file contains hidden or 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
| # be root :-) | |
| sudo su - | |
| cd /tmp | |
| # remove existing | |
| yum -y remove ruby | |
| # install dependencies | |
| yum -y groupinstall 'Development Tools' |
NewerOlder