Sha256: f25511f5ca9b65118b7cf29e582af45567f5d9e58605a0b6569401f948ebd2cb

Contents?: true

Size: 737 Bytes

Versions: 2

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

require "bario/bar"

module Bario
  # Null version of Bar
  class NullBar
    def created_at
      Time.now.utc
    end

    def updated_at
      Time.now.utc
    end

    def name
      ""
    end

    def root
      false
    end

    def total
      0
    end

    def current
      0
    end

    def percent
      0.0
    end

    def bars
      []
    end

    def add_bar(_opts = {})
      self.class.new
    end

    private

    def method_missing(method, *args, &block)
      if respond_to?(method)
        nil
      else
        super
      end
    end

    def respond_to_missing?(method_name, _include_private = false)
      Bario::Bar.instance_methods.include?(method_name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bario-0.1.2 lib/bario/null_bar.rb
bario-0.1.1 lib/bario/null_bar.rb