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
# Work around https://bugs.ruby-lang.org/issues/6104 | |
if RUBY_VERSION =~ /^1\.9/ && RUBY_REVISION < 34865 | |
class File | |
class << self | |
def join_with_encoding_fix(*args) | |
target_encoding = args.first.to_s.encoding | |
aligned_args = args.map { |arg| arg.to_s.dup.encode!(target_encoding) } | |
join_without_encoding_fix(*aligned_args).force_encoding(target_encoding) | |
end | |
alias_method :join_without_encoding_fix, :join |
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
require 'date' | |
module Nordea | |
module NDA | |
class Record | |
def self.parse(str) | |
self.new(str).normalized | |
end | |
def initialize(str) |
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
@value or= do -> | |
1 + 2 |
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 Repo | |
def initialize(path) | |
@path = path | |
end | |
def commits | |
@commits ||= log. | |
gsub(/\t/, " "). # remove tabs | |
split('$$'). # split by marker | |
select { |commit| commit != "" }. # only consider non-empty |
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 Stat | |
def initialize(raw) | |
@raw = raw | |
end | |
def file | |
@file ||= parse_file_from_raw | |
end | |
def name |
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
puts 'foo' | |
class Foo | |
@@loaded ||= [] | |
@@loaded << 'foo.rb' | |
def foo | |
'Foo#foo in foo' | |
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
#!/usr/bin/ruby | |
seed = <<eos | |
.......... | |
.......... | |
..#....... | |
...#...... | |
...##..... | |
...##..... | |
....#..... |
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
# Always wanted to chain comparisons the snaky way? | |
# | |
# puts 'Right there!' if 5 < x <= 15 | |
# | |
# There you go. | |
# May be used under the terms of the MIT License | |
# Contributors: Tero Tilus <[email protected]>, Jan Steffens | |
class FalseClass |
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 is a snippet from my ~/.irbrc | |
# You need to gem install ruby2ruby ParseTree | |
# This is what you do with it | |
# | |
# > class Bar; define_method(:foo) { 'ou hai' }; end | |
# > puts Bar.to_ruby | |
# class Bar < Object | |
# def foo | |
# "ou hai" |
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 ScreenshotFormatter < Cucumber::Formatter::Pretty # Cucumber::Ast::Visitor | |
def self.browser=(browser) | |
@@browser = browser | |
end | |
def self.screenshot_path=(path) | |
@@sspath = path | |
end |
NewerOlder