Class: TellThem::TellThemStore

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tell-them/tell-them.rb

Instance Method Summary collapse

Constructor Details

#initializeTellThemStore

Returns a new instance of TellThemStore.



167
168
169
# File 'lib/tell-them/tell-them.rb', line 167

def initialize
  reset
end

Instance Method Details

#add(data) ⇒ Object



176
177
178
# File 'lib/tell-them/tell-them.rb', line 176

def add(data)
  data.each { |k,v| @data_store[k] = v }
end

#dataObject



188
189
190
# File 'lib/tell-them/tell-them.rb', line 188

def data
  @data_store
end

#enable_media_queries(data) ⇒ Object



180
181
182
# File 'lib/tell-them/tell-them.rb', line 180

def enable_media_queries(data)
  @media_queries = data
end

#has_data?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/tell-them/tell-them.rb', line 184

def has_data?
  @data_store.any?
end

#has_media_grid_info?Boolean

Returns:

  • (Boolean)


196
197
198
199
200
201
202
203
204
# File 'lib/tell-them/tell-them.rb', line 196

def has_media_grid_info?
  return false unless has_media_queries?
  @media_queries.each do |mq|
    next unless mq.has_key?(:columns)
    return true if mq[:columns] == 1 && mq.has_key?(:margins)
    return true if mq[:columns] > 1 && mq.has_key?(:column_width) && mq.has_key?(:column_space)
  end
  false
end

#has_media_queries?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'lib/tell-them/tell-them.rb', line 192

def has_media_queries?
  @media_queries.any?
end

#media_grid_max_columnsObject



210
211
212
213
214
# File 'lib/tell-them/tell-them.rb', line 210

def media_grid_max_columns
  columns = 0
  media_queries.each { |mq| columns = [columns, mq[:columns]].max }
  columns
end

#media_queriesObject



206
207
208
# File 'lib/tell-them/tell-them.rb', line 206

def media_queries
  @media_queries
end

#resetObject



171
172
173
174
# File 'lib/tell-them/tell-them.rb', line 171

def reset
  @data_store = {}
  @media_queries = []
end