Module: Tamiyo

Defined in:
lib/tamiyo/value.rb,
lib/tamiyo/card.rb,
lib/tamiyo/sets.rb,
lib/tamiyo/process.rb,
lib/tamiyo/version.rb,
lib/tamiyo/data_store.rb,
lib/tamiyo/dummy_scrape.rb,
lib/tamiyo/scrape_parser.rb,
lib/tamiyo/yaml/yaml_sink.rb,
lib/tamiyo/gatherer_scrape.rb,
lib/tamiyo/export_all_chain.rb,
lib/tamiyo/yaml/yaml_helper.rb,
lib/tamiyo/yaml/yaml_source.rb,
lib/tamiyo/cockatrice_db_sink.rb,
lib/tamiyo/dummy_scrape_chain.rb,
lib/tamiyo/gatherer_scrape_chain.rb

Overview

The MIT License (MIT) Copyright © 2011 Tom Crayford Refer to rubygems.org/gems/values

Defined Under Namespace

Modules: Process, Yaml, YamlHelper Classes: CockatriceDbSink, DataStore, DummyScrape, DummyScrapeChain, ExportAllChain, GathererScrape, GathererScrapeChain, ScrapeParser, Sets, Value

Constant Summary collapse

Card =
Value.new(:name, :cost, :colors, :type, :text, :pt, :loyalty,
                 :table_row, :played_tapped, :picture_url) do
  def with_name(new_name)
    Card.new(new_name, cost, colors, type, text,
             pt, loyalty, table_row, played_tapped, picture_url)
  end

  def with_extra_colors(extra_colors)
    new_colors = (colors + extra_colors).uniq
    Card.new(name, cost, new_colors, type, text,
             pt, loyalty, table_row, played_tapped, picture_url)
  end

  def with_cost(new_cost)
    Card.new(name, new_cost, colors, type, text,
             pt, loyalty, table_row, played_tapped, picture_url)
  end

  def with_text(new_text)
    Card.new(name, cost, colors, type, new_text,
             pt, loyalty, table_row, played_tapped, picture_url)
  end

  def with_flip_bottom(card)
    new_text = [card.name, card.type, card.text, card.pt].compact.join "\n"
    with_text merge_parts(text, new_text)
  end

  def with_right_split(right_cost, right_text)
    card = with_cost [cost, right_cost]
    card.with_text merge_split(text, right_text)
  end

  def with_left_split(left_cost, left_text)
    card = with_cost [left_cost, cost]
    card.with_text merge_split(left_text, text)
  end

  def with_transform_hint(back_name)
    with_text [text, "[Transforms into #{back_name}]"].join "\n"
  end

  def merge_parts(left_text, right_text)
    [left_text, right_text].join text_part_separator
  end

  def merge_split(left_text, right_text)
    fuse = right_text.match for_fuse_line
    [without_fuse_line(left_text),
     without_fuse_line(right_text),
     fuse && fuse[:text]
    ].compact.join text_part_separator
  end

  def without_fuse_line(text)
    text.gsub match_fuse_line, ''
  end

  def inspect
    ["Name: #{name}",
     "Cost: #{cost}",
     "Color identity: #{colors.join}",
     "Card type: #{type}",
     'Rules text:',
     text,
     pt && "P/T: #{pt}",
     loyalty && "Loyalty: #{loyalty}",
     "Row: #{table_row}",
     "Played tapped: #{played_tapped}",
     "Picture url: #{picture_url}"
    ].compact.join "\n"
  end

  private

  def text_part_separator
    "\n---\n"
  end

  def match_fuse_line
    /\n(?<text>Fuse.*)\z/
  end

  alias for_fuse_line match_fuse_line
end
VERSION =
"0.3.2"