class PollsterChartPollQuestions

Constants

HeaderLineRegex

Public Class Methods

from_tsv(tsv) click to toggle source
# File lib/pollster/models/pollster_chart_poll_questions.rb, line 81
def self.from_tsv(tsv)
  lines = tsv.split(/(?:\r?\n)+/).reject(&:empty?)
  if m = HeaderLineRegex.match(lines[0])
    labels = m[:labels].split(/\t/)
    rows = lines[1..-1].map { |tsv_line| PollsterChartPollQuestion.from_tsv_line_with_labels(tsv_line, labels) }
    PollsterChartPollQuestions.new(rows)
  else
    raise ArgumentError.new("First line of TSV is `#{lines[0]}`, which does not match Pollster::PollsterChartPollQuestions::HeaderLineRegex")
  end
end
new(array) click to toggle source
# File lib/pollster/models/pollster_chart_poll_questions.rb, line 73
def initialize(array)
  @array = array
end

Public Instance Methods

each(&block) click to toggle source
# File lib/pollster/models/pollster_chart_poll_questions.rb, line 77
def each(&block)
  @array.each(&block)
end