class Tamiyo::Yaml::YamlSink
Public Instance Methods
pump()
click to toggle source
# File lib/tamiyo/yaml/yaml_sink.rb, line 11 def pump with_the_cards_file do emit_block_sequence do @chain.pull.each do |card| emit_block_mapping do emit_pair 'name', card.name emit_pair_with_sequence_value 'identity', card.colors unless card.colors.empty? emit_pair_with_optional_sequence_value 'mana cost', card.cost emit_pair 'type', card.type emit_pair_with_literal_value 'text', card.text emit_pair 'pt', card.pt if card.pt emit_pair 'loyalty', card.loyalty if card.loyalty emit_pair 'played tapped', 'true' if card.played_tapped emit_pair 'row', card.table_row.to_s end end end end end
with_the_cards_file(&block)
click to toggle source
# File lib/tamiyo/yaml/yaml_sink.rb, line 31 def with_the_cards_file(&block) store = DataStore.new file_name = store.path_for 'cards.yaml' if block_given? File.open(file_name, 'w') do |file| within_a_yaml_document_of file, &block end end end
within_a_yaml_document_of(file) { || ... }
click to toggle source
# File lib/tamiyo/yaml/yaml_sink.rb, line 41 def within_a_yaml_document_of(file) setup_yaml_emitter_for file emit_start_of_one_document yield emit_end_of_one_document end