Sha256: b7e75deda821b935b315cf61e80fafc60426b5143fb9d551bfd0a1d281ed1708
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require_relative 'signature' require_relative 'tags' module Signore class SigFromStream def self.sig_from(input, tags: Tags.new) new(input, tags: tags).to_sig end def initialize(input, tags: Tags.new) @input = input @tags = tags end def to_sig Signature.new(author: params.author, source: params.source, subject: params.subject, tags: tags.required, text: params.text) end private attr_reader :input, :tags Params = Struct.new(:text, :author, :subject, :source) def get_param(param) return get_text if param == :text puts puts "#{param}?" input.gets.strip end # :reek:FeatureEnvy def get_text # rubocop:disable AccessorMethodName puts 'text?' value = '' value += input.gets until value.lines.to_a.last == "\n" value.strip end def params @params ||= Params.new(*Params.members.map(&method(:get_param))) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signore-0.6.0 | lib/signore/sig_from_stream.rb |