code
stringlengths
1
1.73M
language
stringclasses
1 value
$:.unshift File.join(File.dirname(__FILE__)) require 'test_helper' class TestUpperScore < Test::Unit::TestCase def test_odds_1 t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 6})) u_score = Yahtzee::UpperScore.new(t,1) assert_equal( 1, u_score.odds ) end def test_odds_1 t = Yahtzee::T...
Ruby
require 'test/unit' require 'find' Find.find( File.join(File.dirname(__FILE__) ) ) do |path| require path if path.split(/\//).last().match(/^test.*\.rb$/) end
Ruby
$:.unshift File.join(File.dirname(__FILE__)) require 'test_helper' class TestTurn < Test::Unit::TestCase def test_turn_over_no_rolls t = Yahtzee::Turn.new assert !t.over? end def test_turn_over_one_roll t = Yahtzee::Turn.new t.roll assert !t.over? end def test_turn_over_two_rolls ...
Ruby
$:.unshift File.join(File.dirname(__FILE__),"..","lib") require 'dice' def try_X_ones_on_first_roll(init_dice, number=6, number_of_dice = 6) d = Dice.new(init_dice,number_of_dice) # let's verify some things just to be sure raise "dice were all not kept" unless d.to_hash == init_dice # jus...
Ruby
require 'yahtzee/yahtzee_game' require 'yahtzee/dice' require 'yahtzee/score' require 'yahtzee/upper_score' require 'yahtzee/turn'
Ruby
require 'rubygems' require 'facets/core/enumerable/sum' module Yahtzee class Dice include Enumerable def initialize(all = {}, die_count = 6) @all = all @die_count = die_count (1..@die_count).each { |x| @all[x] = 0 } if @all.size == 0 end def roll(keep = []) (1..@die...
Ruby
class YahtzeeGame def initialize() @upper_scored = {} end def play() while @upper_scored.length < 6 turn = Yahtzee::Turn.new keep_dice = [] while !turn.over? turn.roll(keep_dice) update_keep_dice(turn.dice,keep_dice) unless turn.yahtzee? ...
Ruby
module Yahtzee class UpperScore < Yahtzee::Score def initialize(turn,number) super(turn) @number = number end def odds total = dice.to_hash[@number] if total >= 3 return 1 elsif turn.over? return 0 elsif total == 2 return 0.52 ...
Ruby
module Yahtzee #nodoc: class Turn attr_reader :dice attr_reader :roll_count def initialize(dice = Yahtzee::Dice.new) @dice = dice; @roll_count = 0 end def roll(keep = []) raise "Turn is over" if over? @roll_count += 1 @dice.roll(keep) end ...
Ruby
module Yahtzee class Score attr_accessor :turn attr_accessor :dice def initialize(turn) @turn = turn @dice = turn.dice end def odds end def optional_roll? end def points end end end
Ruby
module Yahtzee class ScoreCard def initialize() end def update( dice ) end end end
Ruby
$:.unshift File.dirname(__FILE__) require 'yahtzee' y = YahtzeeGame.new.play
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/liberalxmlparser' XMLELEM = /<(\w+\s*)((?:[-:\w]+="[^"]*"\s*)+)(\/?)>/ def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser) sortattrs = proc {"<#{$1+$2.split.sort.join(' ')+$3}>"} document = parser.parse(input.chomp, :lowercase_at...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/inputstream' class HTMLInputStreamTest < Test::Unit::TestCase include HTML5 def getc stream if String.method_defined? :force_encoding stream.char.force_encoding('binary') else stream.char end end def test_char_ascii...
Ruby
require 'html5/constants' class TokenizerTestParser def initialize(tokenizer) @tokenizer = tokenizer end def parse @outputTokens = [] debug = nil for token in @tokenizer debug = token.inspect if token[:type] == :ParseError send(('process' + token[:type].to_s), token) end re...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "html5/cli" class TestCli < Test::Unit::TestCase def test_open_input assert_equal $stdin, HTML5::CLI.open_input('-') assert_kind_of StringIO, HTML5::CLI.open_input('http://whatwg.org/') assert_kind_of File, HTML5::CLI.open_input('testdata/site...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "html5/sniffer" class TestFeedTypeSniffer < Test::Unit::TestCase include HTML5 include TestSupport include Sniffer html5_test_files('sniffer').each do |test_file| test_name = File.basename(test_file).sub('.test', '') tests = JSON.parse(F...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/treewalkers' require 'html5/treebuilders' $tree_types_to_test = { 'simpletree' => {:builder => HTML5::TreeBuilders['simpletree'], :walker => HTML5::TreeWalkers['simpletree']}, 'rexml' => {:builder => HTM...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/serializer' require 'html5/treewalkers' #Run the serialize error checks checkSerializeErrors = false class JsonWalker < HTML5::TreeWalkers::Base def each @tree.each do |token| case token[0] when 'StartT...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/inputstream' class Html5EncodingTestCase < Test::Unit::TestCase include HTML5 include TestSupport begin require 'rubygems' require 'UniversalDetector' def test_chardet #TODO: can we get rid of this? file = File.open(File.jo...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/treebuilders' require 'html5/html5parser' require 'html5/cli' $tree_types_to_test = ['simpletree', 'rexml'] begin require 'hpricot' $tree_types_to_test.push('hpricot') rescue LoadError end class Html5ParserTestCase < Test::Unit::TestCase inc...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/tokenizer' require 'tokenizer_test_parser' class Html5TokenizerTestCase < Test::Unit::TestCase def assert_tokens_match(expectedTokens, receivedTokens, ignoreErrorOrder, message) if !ignoreErrorOrder assert_equal expectedTokens, receive...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "test/unit" require "html5/inputstream" class TestHtml5Inputstream < Test::Unit::TestCase def test_newline_in_queue stream = HTML5::HTMLInputStream.new("\nfoo") stream.unget(stream.char) assert_equal [1, 0], stream.position end def test...
Ruby
require 'test/unit' HTML5_BASE = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))) if File.exists?(File.join(HTML5_BASE, 'ruby', 'testdata')) TESTDATA_DIR = File.join(HTML5_BASE, 'ruby', 'testdata') else TESTDATA_DIR = File.join(HTML5_BASE, 'testdata') end $:.unshift File.join(File.dirname(Fi...
Ruby
#!/usr/bin/env ruby -wKU require File.join(File.dirname(__FILE__), 'preamble') require 'html5' require 'html5/filters/validator' class TestValidator < Test::Unit::TestCase def run_validator_test(test) p = HTML5::HTMLParser.new(:tokenizer => HTMLConformanceChecker) p.parse(test['input']) errorCodes = p....
Ruby
#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/liberalxmlparser' require 'html5/treewalkers' require 'html5/serializer' require 'html5/sanitizer' class SanitizeTest < Test::Unit::TestCase include HTML5 def sanitize_xhtml stream XHTMLParse...
Ruby
# # This temporary test driver tracks progress on getting HTML5lib working # on Ruby 1.9. Prereqs of Hoe, Hpricot, and UniversalDetector will be # required to complete this. # # Once all the tests pass, this file should be deleted # require 'test/test_cli' # requires UniversalDetector # require 'test/test_encoding'...
Ruby
require 'rake' require 'hoe' require 'lib/html5/version' Hoe.new("html5", HTML5::VERSION) do |p| p.name = "html5" p.description = p.paragraphs_of('README', 2..5).join("\n\n") p.summary = "HTML5 parser/tokenizer." p.author = ['Ryan King'] # TODO: add more names p.email = 'ryan@theryanking.com' p.url ...
Ruby
require 'html5/treewalkers/base' module HTML5 module TreeWalkers class << self def [](name) case name.to_s.downcase when 'simpletree' require 'html5/treewalkers/simpletree' SimpleTree::TreeWalker when 'rexml' require 'html5/treewalkers/rexml' ...
Ruby
require 'html5/serializer/htmlserializer' module HTML5 class XHTMLSerializer < HTMLSerializer DEFAULTS = { :quote_attr_values => true, :minimize_boolean_attributes => false, :use_trailing_solidus => true, :escape_lt_in_attrs => true, :omit_optional_tags ...
Ruby
require 'html5/constants' module HTML5 class HTMLSerializer def self.serialize(stream, options = {}) new(options).serialize(stream, options[:encoding]) end def escape(string) string.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;") end def initialize(options={}) @quote...
Ruby
require 'html5/constants' module HTML5 module TreeWalkers module TokenConstructor def error(msg) {:type => "SerializeError", :data => msg} end def normalize_attrs(attrs) attrs.to_a end def empty_tag(name, attrs, has_children=false) error(_("Void element has children")) if has_children {:typ...
Ruby
require 'html5/treewalkers/base' module HTML5 module TreeWalkers module SimpleTree class TreeWalker < HTML5::TreeWalkers::Base include HTML5::TreeBuilders::SimpleTree def walk(node) case node when Document, DocumentFragment return when DocumentTyp...
Ruby
require 'html5/treewalkers/base' require 'rexml/document' module HTML5 module TreeWalkers module Hpricot class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker def node_details(node) case node when ::Hpricot::Elem if node.name.empty? [:DOCUMENT_...
Ruby
require 'html5/treewalkers/base' require 'rexml/document' module HTML5 module TreeWalkers module REXML class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker def node_details(node) case node when ::REXML::Document [:DOCUMENT] when ::REXML::Element ...
Ruby
$:.unshift File.dirname(__FILE__), 'lib' require 'html5' require 'ostruct' require 'optparse' module HTML5::CLI def self.parse_opts argv options = OpenStruct.new options.profile = false options.time = false options.output = :html options.treebuilder = 'simpletree' ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterBodyPhase < Phase handle_start 'html' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCharacters data ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterHeadPhase < Phase handle_start 'html', 'body', 'frameset', %w( base link meta script style title ) => 'FromHead' handle_end %w( body html br ) => 'BodyHtmlBr' def process_eof anything_else @parser.phase.process_eof end def p...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTableBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table0 handle_start 'html', 'tr', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead ) => 'TableOther' handle_end 'table', %w( tbody tfoot thead ) =...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterBodyPhase < Phase handle_end 'html' def processComment(data) # This is needed because data is to be appended to the <html> element # here and not to whatever is currently open. @tree.insert_comment(data, @tree.open_elements.first) ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InColumnGroupPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-column handle_start 'html', 'col' handle_end 'colgroup', 'col' def ignoreEndTagColgroup @tree.open_elements[-1].name == 'html' end def processChar...
Ruby
require 'html5/html5parser/phase' module HTML5 class InForeignContentPhase < Phase def processCharacters(data) @tree.insertText(data) end def startTagOther(name, attributes, self_closing) if !%w[mglyph malignmark].include?(name) && %w[mi mo mn ms mtext].include?(@tree.open_elements.last.nam...
Ruby
require 'html5/html5parser/phase' module HTML5 class InHeadPhase < Phase handle_start 'html', 'head', 'title', 'style', 'script', 'noscript' handle_start %w( base link meta) handle_end 'head' handle_end %w( html body br ) => 'ImplyAfterHead' handle_end %w( title style script noscript ) def...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-select handle_start 'html', 'option', 'optgroup', 'select' handle_start 'input' handle_end 'option', 'optgroup', 'select', %w( caption table tbody tfoot thead tr td th ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset handle_start 'html', 'frameset', 'frame', 'noframes' handle_end 'frameset', 'noframes' def processCharacters(data) parse_error("unexpected-char-in-fr...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterFramesetPhase < Phase handle_start 'html', 'noframes' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCha...
Ruby
require 'html5/html5parser/phase' module HTML5 class InitialPhase < Phase # This phase deals with error handling as well which is currently not # covered in the specification. The error handling is typically known as # "quirks mode". It is expected that a future version of HTML5 will define this. d...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCaptionPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-caption handle_start 'html', %w(caption col colgroup tbody td tfoot th thead tr) => 'TableElement' handle_end 'caption', 'table', %w(body col colgroup html tbody td tfoot...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTablePhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table handle_start 'html', 'caption', 'colgroup', 'col', 'table' handle_start %w( tbody tfoot thead ) => 'RowGroup', %w( td th tr ) => 'ImplyTbody' handle_start %w(sty...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHtmlPhase < Phase def process_eof insert_html_element @parser.phase.process_eof end def processComment(data) @tree.insert_comment(data, @tree.document) end def processSpaceCharacters(data) end def processChar...
Ruby
module HTML5 # Base class for helper objects that implement each phase of processing. # # Handler methods should be in the following order (they can be omitted): # # * EOF # * Comment # * Doctype # * SpaceCharacters # * Characters # * StartTag # - startTag* methods # * EndTag ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#after3 handle_start 'html', 'noframes' handle_end 'html' def processCharacters(data) parse_error("unexpected-char-after-frameset") end def startTagNo...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHeadPhase < Phase handle_start 'html', 'head' handle_end %w( head br ) => 'ImplyHead' def process_eof startTagHead('head', {}) @parser.phase.process_eof end def processSpaceCharacters(data) end def processCharacte...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCellPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-cell handle_start 'html', %w( caption col colgroup tbody td tfoot th thead tr ) => 'TableOther' handle_end %w( td th ) => 'TableCell', %w( body caption col colgroup html ) =...
Ruby
require 'html5/html5parser/phase' module HTML5 class InRowPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-row handle_start 'html', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead tr ) => 'TableOther' handle_end 'tr', 'table', %w( tbody tfoot thead ) => 'Tab...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectInTablePhase < Phase handle_start %w(caption table tbody tfoot thead tr td th) => 'Table' handle_end %w(caption table tbody tfoot thead tr td th) => 'Table' def processCharacters(data) @parser.phases[:inSelect].processCharacters(data) end ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-body handle_start 'html' handle_start %w(base link meta script style title) => 'ProcessInHead' handle_start 'body', 'form', 'plaintext', 'a', 'button', 'xmp', 'table', '...
Ruby
module HTML5 module TreeBuilders class << self def [](name) case name.to_s.downcase when 'simpletree' then require 'html5/treebuilders/simpletree' SimpleTree::TreeBuilder when 'rexml' then require 'html5/treebuilders/rexml' REXML::TreeBuilder ...
Ruby
module HTML5 class EOF < Exception; end def self._(str); str end CONTENT_MODEL_FLAGS = [ :PCDATA, :RCDATA, :CDATA, :PLAINTEXT ] SCOPING_ELEMENTS = %w[ applet button caption html marquee object table td th ] FORMATTING_ELEME...
Ruby
# adapted from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Sof...
Ruby
require 'html5/constants' require 'html5/filters/base' module HTML5 module Filters class WhitespaceFilter < Base SPACE_PRESERVE_ELEMENTS = %w[pre textarea] + RCDATA_ELEMENTS SPACES = /[#{SPACE_CHARACTERS.join('')}]+/m def each preserve = 0 __getobj__.each do |token| ...
Ruby
require 'delegate' require 'enumerator' module HTML5 module Filters class Base < SimpleDelegator include Enumerable end end end
Ruby
require 'html5/filters/base' module HTML5 module Filters class InjectMetaCharset < Base def initialize(source, encoding) super(source) @encoding = encoding end def each state = :pre_head meta_found = @encoding.nil? pending = [] __getobj__.each d...
Ruby
# borrowed from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the So...
Ruby
require 'html5/constants' require 'html5/filters/base' module HTML5 module Filters class OptionalTagFilter < Base def slider previous1 = previous2 = nil __getobj__.each do |token| yield previous2, previous1, token if previous1 != nil previous2 = previous1 prev...
Ruby
# adapted from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Sof...
Ruby
# HTML 5 conformance checker # # Warning: this module is experimental, incomplete, and subject to removal at any time. # # Usage: # >>> from html5lib.html5parser import HTMLParser # >>> from html5lib.filters.validator import HTMLConformanceChecker # >>> p = HTMLParser(tokenizer=HTMLConformanceChecker) # >>> p.parse('...
Ruby
require 'html5/filters/base' require 'html5/sanitizer' module HTML5 module Filters class HTMLSanitizeFilter < Base include HTMLSanitizeModule def each __getobj__.each do |token| yield(sanitize_token(token)) end end end end end
Ruby
module HTML5 module Sniffer # 4.7.4 def html_or_feed str s = str[0, 512] # steps 1, 2 pos = 0 while pos < s.length case s[pos] when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR pos += 1 when ?< # 0x3C pos += 1 if s[pos..pos+2] == "!--" # [0...
Ruby
require 'stringio' require 'html5/constants' module HTML5 # Provides a unicode stream of characters to the HTMLTokenizer. # This class takes care of character encoding and removing or replacing # incorrect byte-sequences and also provides column and line tracking. class HTMLInputStream attr_accessor :q...
Ruby
# Warning: this module is experimental and subject to change and even removal # at any time. # # For background/rationale, see: # * http://www.intertwingly.net/blog/2007/01/08/Xhtml5lib # * http://tinyurl.com/ylfj8k (and follow-ups) # # References: # * http://googlereader.blogspot.com/2005/12/xml-errors-in-feeds....
Ruby
module HTML5 VERSION = '0.10.1' end
Ruby
require 'html5/serializer/htmlserializer' require 'html5/serializer/xhtmlserializer'
Ruby
require 'cgi' require 'html5/tokenizer' require 'set' module HTML5 # This module provides sanitization of XHTML+MathML+SVG # and of inline style attributes. # # It can be either at the Tokenizer stage: # # HTMLParser.parse(html, :tokenizer => HTMLSanitizer) # # or, if you already have a parse tree (in this exam...
Ruby
require 'html5/constants' require 'html5/tokenizer' require 'html5/treebuilders/rexml' Dir.glob(File.join(File.dirname(__FILE__), 'html5parser', '*_phase.rb')).each do |path| require 'html5/html5parser/' + File.basename(path) end module HTML5 # Error in parsed document class ParseError < Exception; end class...
Ruby
require 'html5/constants' require 'html5/inputstream' module HTML5 # This class takes care of tokenizing HTML. # # * @current_token # Holds the token that is currently being processed. # # * @state # Holds a reference to the method to be invoked... XXX # # * @states # Holds a mapping between...
Ruby
require 'html5/constants' #XXX - TODO; make the default interface more ElementTree-like rather than DOM-like module HTML5 # The scope markers are inserted when entering buttons, object elements, # marquees, table cells, and table captions, and are used to prevent formatting # from "leaking" into tables, button...
Ruby
require 'html5/treebuilders/base' module HTML5 module TreeBuilders module SimpleTree class Node < Base::Node # Node representing an item in the tree. # name - The tag name associated with the node attr_accessor :name # The value of the current node (applies to text nodes a...
Ruby
require 'html5/treebuilders/base' require 'rubygems' require 'hpricot' require 'forwardable' module HTML5 module TreeBuilders module Hpricot class Node < Base::Node extend Forwardable def_delegators :@hpricot, :name attr_accessor :hpricot def initialize(name) s...
Ruby
require 'html5/treebuilders/base' require 'rexml/document' require 'forwardable' module HTML5 module TreeBuilders module REXML class Node < Base::Node extend Forwardable def_delegators :@rxobj, :name, :attributes attr_accessor :rxobj def initialize name super nam...
Ruby
require 'html5/html5parser' require 'html5/version' module HTML5 def self.parse(stream, options={}) HTMLParser.parse(stream, options) end def self.parse_fragment(stream, options={}) HTMLParser.parse_fragment(stream, options) end end
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
#!/usr/bin/env ruby # ===== Yahoo LifeType demo For Ruby - listClasses ===== # Coded by CFC < zusocfc at gmail dot com > APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType...
Ruby
#!/usr/bin/env ruby # ===== Yahoo LifeType demo For Ruby - listClasses ===== # Coded by CFC < zusocfc at gmail dot com > APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML, LifeType biz = Biz.new(APPID) puts "讀取商家資料中... 請稍後" rsp = Do...
Ruby
#!/usr/bin/env ruby # ===== Yahoo LifeType demo For Ruby - listClasses ===== # Coded by CFC < zusocfc at gmail dot com > APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType...
Ruby
#!/usr/bin/env ruby # ===== Yahoo LifeType demo For Ruby - listClasses ===== # Coded by CFC < zusocfc at gmail dot com > APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML, LifeType biz = Biz.new(APPID) puts "讀取商家資料中... 請稍後" rsp = Do...
Ruby
# This is only for loading lib/lifetype.rb. require 'lib/lifetype'
Ruby
# =Ruby API for Yahoo! LifeType # # See http://tw.developer.yahoo.com/lifestyle_api.html # (C) 2008 Hsu-Shih-Chung < CFC > # http://blog.pixnet.net/zusocfc # # === LICENSE: # # BSD(-compatible) # # === EXAMPLE: # See folder named examples. # # === HISTORY: # - 0.3 2008-04-17: Bug fix(Parameters c...
Ruby
#!/usr/bin/env ruby APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType::Class.new(APPID).listClasses) puts "獲取類別結束" puts "類別總數: " + doc.get_elements("//rsp/ClassList")[0].at...
Ruby
#!/usr/bin/env ruby APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType::Class.new(APPID).listClasses) puts "獲取類別結束" puts "類別總數: " + doc.get_elements("//rsp/ClassList")[0].at...
Ruby
# This is only for loading lib/lifetype.rb. require 'lib/lifetype'
Ruby
# =Ruby API for Yahoo! LifeType # # See http://tw.developer.yahoo.com/lifestyle_api.html # (C) 2008 Hsu-Shih-Chung < CFC > # http://blog.pixnet.net/zusocfc # # === LICENSE: # # BSD(-compatible) # # === EXAMPLE: # See folder named examples. # # === HISTORY: # - 0.1 2008-04-16: Initial release. # ...
Ruby
#!/usr/bin/env ruby APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType::Class.new(APPID).listClasses) puts "獲取類別結束" puts "類別總數: " + doc.get_elements("//rsp/ClassList")[0].at...
Ruby
#!/usr/bin/env ruby APPID = "NhYX9XjV34FPxdq7zD8T7wwc4QGI5VWu_48NHh03zbPYUfPpcWrpZzhcVDKFQsH9dQ--" require 'lifetype' require 'rexml/document' include REXML puts "獲取生活+類別中... 請稍後" doc = Document.new(LifeType::Class.new(APPID).listClasses) puts "獲取類別結束" puts "類別總數: " + doc.get_elements("//rsp/ClassList")[0].at...
Ruby
# This is only for loading lib/lifetype.rb. require 'lib/lifetype'
Ruby
# =Ruby API for Yahoo! LifeType # # See http://tw.developer.yahoo.com/lifestyle_api.html # (C) 2008 Hsu-Shih-Chung < CFC > # http://blog.pixnet.net/zusocfc # # === LICENSE: # # BSD(-compatible) # # === EXAMPLE: # See folder named examples. # # === HISTORY: # - 0.2 2008-04-17: Bug fix(Bad URL) # ...
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
Ruby
class CreatePolls < ActiveRecord::Migration def change create_table :polls do |t| t.string :title t.string :author_email t.timestamps end end end
Ruby
class CreateVotes < ActiveRecord::Migration def change create_table :votes do |t| t.integer :poll_id t.string :yana t.timestamps end end end
Ruby