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
module MyAccessor | |
def method_missing(method_id, *args) | |
@storage ||= {} | |
m = method_id.to_s | |
missing_accessor = m[/get_(.*)/, 1] | |
return @storage[missing_accessor] if missing_accessor | |
missing_setter = m[/set_(.*)/, 1] |
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 ClassWithAttr | |
def self.my_attr_accessor(attr_name) | |
define_method("#{attr_name.to_s}=") do |arg| | |
instance_variable_set("@#{attr_name}", arg) | |
end | |
define_method("#{attr_name.to_s}") do | |
instance_variable_get("@#{attr_name}") | |
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
class EmployeeData | |
attr_accessor :first_name, :last_name | |
attr_accessor :dates | |
end | |
var record = EmployeeData.new("Dan", "Wellman", { | |
Date.new("1/1/2001") => 38.5 # hours actually worked on that day | |
}) | |
data = [record] |
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/env ruby | |
# Downloads "Payment Received" transactions from the EasyPayMetrocard | |
# website (www.easypaymetrocard.com"). | |
# | |
# Requires capybara and capybara-webkit for headless JavaScript execution - | |
# the EasyPayMetroCard site requires JavaScript to obtain account activity. | |
# | |
# To install capybara-webkit, you must first install Qt, a cross-platform | |
# development kit. For instructions, see |
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 'socket' | |
# This Behavior implements the same interface as BehaviorServer since we must set up our connection | |
# differently than GServer (the base class of BehaviorServer) does. This means we won't be able to define | |
# this behavior in the same was as other behaviors. Something will have to change to unify these. | |
class FullListenQueue | |
def initialize(port) | |
@port = port | |
end |