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 | |
require "rubygems" | |
require "rspec" | |
require "./step1" | |
describe Hoge do | |
describe :initialize do | |
subject { Hoge.new( 100, 1000) } | |
it "インスタンス変数aに100が代入されること" do | |
subject.a.should == 100 |
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 | |
require "rubygems" | |
class Hoge | |
attr_reader :a, :b | |
#aとbをインスタンス変数に格納する | |
def initialize a, b | |
@a = a | |
@b = b | |
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 User < ActiveRecord::Base | |
has_one :profile | |
end | |
class User::Profile < ActiveRecord::Base | |
belongs_to :profile | |
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
Header set Pragma no-cache | |
Header set Cache-Control no-cache | |
Header set Expires "Thu, 01 Dec 1994 16:00:00 GMT" |
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 | |
class Hoge : | |
@classmethod | |
def parse(cls, filepath) : | |
#TODO: ここにパースする処理 |
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 | |
require "rexml/element" | |
class Hoge | |
def self.parse(filepath) | |
#TODO: パース処理 | |
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
#coding :utf-8 | |
class Hoge | |
def self.say_hoge | |
puts "hoge" | |
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
#coding: utf-8 | |
class Hoge : | |
@classmethod | |
def say_hoge(cls) : | |
print "hoge" |
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 | |
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") |