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 Ohta < ::Chu2Byou | |
include ::Rock::90::Nirvana | |
include ::Rock::90::Radiohead | |
include ::Book::MishimaYukio | |
def suicide | |
raise NotImplementedError | |
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
#attrs = { foo: "foo", bar: "bar", baz: "baz" ,,,,} | |
class DefineMethodSample | |
def initialize(attrs) | |
attrs.symbolize_keys! | |
attrs.each do |k, v| | |
self.class.send(:define_method, k) { return(v) } | |
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
group :test do | |
gem "rspec-rails", '>=2.0.0' | |
gem "rspec", '>=2.0.0' | |
gem "rspec-core", '>=2.0.0' | |
gem "rspec-expectations", '>=2.0.0' | |
gem "rspec-mocks", '>=2.0.0' | |
gem 'email_spec' | |
gem 'rr' | |
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
require 'digest/md5' | |
class Hoge | |
def initialize | |
@data = nil | |
end | |
def data=(data) | |
@data = Digest::MD5::hexdigest(data) | |
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
#sample code | |
class Hoge | |
def say(message=nil) | |
message ||= "hoge" | |
return message | |
end | |
end | |
#rspec | |
describe Hoge do |
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
#coding: utf-8 | |
#別名メソッドに気をつけよう。 | |
#たとえば | |
#array.mapとarray.collectは同じメソッドです。 | |
#自己破壊メソッドはポインタ参照が変わらないため、変数bは変数aの内容を表示する。 | |
a = [1,2,3] | |
b = a | |
a.reverse! | |
p b |
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
#coding: utf-8 | |
puts "Hello world" |
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
#coding: utf-8 | |
from xml.etree.ElementTree import ElementTree | |
import urllib | |
url = "http://example.com/example.xml" | |
xml = ElementTree(file=urllib.urlopen(url)) | |
for e in list(xml.getroot().getiterator()): | |
if e.tag != None and e.text != None : | |
print e.tag.encode("utf-8") + ":" + e.text.encode("utf-8") |
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
#coding: utf-8 | |
class Hoge | |
strategy = None | |
@classmethod | |
def set_strategy(cls, strategy) : | |
self.strategy = strategy || Piyo | |
@classmethod | |
def say(cls) : | |
return self.strategy.say() |
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
#coding: utf-8 | |
class Hoge : | |
@classmethod | |
def say_hoge(cls) : | |
print "hoge" |
OlderNewer